Fork me on GitHub
#re-frame
<
2016-10-18
>
mikethompson00:10:11

@pupeno we use cljs (and re-frame) within electron

mikethompson00:10:52

We find it fairly painless ... in the main it is just like targetting Chrome

mikethompson00:10:27

> It looks like like 64 of subs.cljc is having the problem. That line looks like it is a comment to me

mikethompson00:10:48

Regarding line 23 of your gist, I can see nothing wrong there. I suspect some surounding problem (unbalanced parens or something?) is misleading you. Nothing obvious.

vikeri06:10:14

@shaun-mahood Thanks for your time and example! I don’t really see how it gives me the ability to use the value of subscriptions as input to handlers though?

pupeno06:10:29

@mikethompson unbalanced paranthesis would stop compilation. That’s not it.

pupeno06:10:29

@mikethompson did you use a template to get started?

mikethompson06:10:47

@pupeno I sometimes use a template to start a project, yes

mikethompson06:10:59

Typically re-frame-template

mikethompson07:10:46

For something more substantial, there https://github.com/luminus-framework/luminus-template which has a +re-frame option

pupeno07:10:04

@mikethompson oh, I started from descjop, for electron integration.

pupeno07:10:25

I think you are right in that it is a surrounding problem, but it’s subtle.

mikethompson07:10:50

I looked fairly carefully at your gist and couldn't see a problem

pupeno07:10:02

Yeah, it’s probably not there.

mikethompson07:10:06

If there is a more general problem it does seem an odd place for it to initially show itself.

pupeno07:10:23

It looks like there’s a problem with the ratom.

pupeno07:10:48

Let me show you...

pupeno07:10:16

holly cow… now it’s working.

pupeno07:10:55

I removed all the changes to project.clj, cleaned the project and rebuilt (which I did like a thousand times) and now it’s working.

pupeno07:10:14

Oh well… moving on.

lxsameer08:10:55

how do you test a function which fetch a value using subscribe ?

mikethompson08:10:26

Something like this:

(defn subscription-stub [x]
  (atom
    (case x
      [:query-id] 42)))

(deftest some-test
  (with-redefs [re-frame/subscribe (subscription-stub)]
    (testing "some rendering"
      ..... somehow call or render the component and check the output)))

shyambalu15:10:53

is there a migration guide for going to 0.8

shaun-mahood15:10:50

@vikeri: Hmm, it might not solve exactly the right problem 🙂 What I was looking at was getting the app-db accessible to any of the subscriptions as you pass them through the different forms - essentially, you could re-make your calculations so that they all depend on app-db, and then the function can be declared somewhere outside of the subscription and used by any event handler or subscription.

shaun-mahood15:10:46

@vikeri: Could you just dispatch an event from within your subscription? I've never tried it so have no idea if it's either possible or a good idea, but is that more along the lines of what you want?

nfisher19:10:58

@agold: I think if you separate it into the container component model that the react/redux community has endorsed I think it simplifies the testing.

nfisher19:10:46

The component becomes a pure function and the container maintains the subscriptions.

nfisher19:10:19

You could optionally inject the component instead of calling it directly as I've illustrated in an article I posted previously: https://junctionbox.ca/2016/09/03/clojurescript-reagent-reframe.html

nfisher19:10:53

@shaun-mahood the app-db is available at a particular point in time with the reg-event-db.

shaun-mahood19:10:11

@shyambalu: Sort of - https://github.com/Day8/re-frame/blob/master/CHANGES.md has the details of what changed, and the docs in https://github.com/Day8/re-frame/tree/master/docs are pretty up to date with info on how to use most of the new features. It's probably worth looking at the examples in https://github.com/Day8/re-frame/tree/master/examples as well. Outside of middleware (if you have any that you've written), everything else should run fine in 0.8 so you can implement the new features one at a time as you determine what changes you want to take advantage of. If you have any specific questions or problems, please post them here and hopefully we can help.

shaun-mahood19:10:51

@nfisher: Yep! Not sure if you saw the rest of the discussion with vikeri above, but I was trying to figure out how to thread the DB values through the fancy new forms of reg-sub - I've never used them before and was seeing how they work. I think I may have answered the wrong question though...

shaun-mahood19:10:31

@nfisher: And please, continue to suggest things to me - I'm a committer on documentation only, and half of that is because I don't know what I'm doing so decided it was the best way to learn 🙂 I miss obvious things pretty often, as I've found a way to use re-frame that works for my projects but there's lots of other use cases and problems that I haven't encountered

nfisher19:10:32

@shaun-mahood think I mixed some of the convos. Soz

nfisher19:10:13

Yes I started on a project doing one big handler and found it unwieldy.

nfisher19:10:39

I made the assumption I could just frame everything with the context provided in the dispatch

nfisher19:10:39

But it got messy quick.

nfisher19:10:46

Wired up nicely when I did the PoC which was just shuffling data between screens but once I started doing calculations and such I started to find it a painful abstraction.

shaun-mahood19:10:42

@nfisher: You aren't the only one to go down that path - it seems like a pretty common approach when starting out. It's gotten a lot nicer with the new fx handlers, a lot of the places where I would have wired up a big, overly complex db-handler have turned into a bunch of nice fx handlers.

nfisher19:10:07

Will need to look at them.

nfisher19:10:34

I’ve just been using subs and events

shaun-mahood19:10:26

@nfisher: It took me quite a bit of work to really get a handle on them, but the nice thing is that you can gradually convert over to them as you decide what makes sense. Let me know if you have any specific questions once you start looking at them, happy to work through some code with you if you want. I've found that a lot of it is determining trade-offs and gradually refactoring until I get to something that feels right, but thankfully it's pretty easy to do.

nfisher19:10:51

@shaun-mahood thanks I started with ReactJS+Redux and started looking at CLJS based on recommendations from a few ppl I know.

nfisher19:10:28

I was already using Clojure hadn’t picked up CLJS/re-frame/etc.

shaun-mahood19:10:06

@nfisher: That's awesome, you know good people 🙂 It's such a nice thing to be able to use Clojure everywhere.

nfisher19:10:56

I’m still trying to figure out a way to do server side rendering that reagent can pick-up once it’s loaded.

nfisher19:10:46

Want to try and do graceful degradation/progressive enhancement

shaun-mahood19:10:57

@nfisher: https://yogthos.net/posts/2015-11-24-Serverside-Reagent.html is the best resource I know for that - it's on my list for future experimentation, but I haven't tried it at all

shaun-mahood19:10:35

There are excellent resources in both Om and Rum for that as well, if you ever decide to branch out and try either of them.

nfisher20:10:04

re-agent was suggested over om from a few ppl.

nfisher20:10:18

I’ll take a look when I have some time.

nfisher20:10:51

I figured by going down the container/component route the component could be used. Looks like @yogthos ran into somethings that I figured would be issues.

shaun-mahood20:10:56

@nfisher: I found reagent more understandable than om as a beginner, but there are definitely trade offs in all of the react libraries - it just depends which things are more important for your use case. One of my favourite things about the whole community is the amount of cross pollination between the different libraries. As far as I know, the approach to server side rendering started with foam (a library for the original om), which inspired the implementation in rum, and then the server side implementation of rum got a bunch of optimization work that inspired some changes in hiccup, and now om.next has full server side rendering as part of it's core implementation. Such a cool thing to be able to watch in a community that is so friendly and excited about new ideas.

nfisher20:10:08

Oh cool 🙂