This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-06-24
Channels
- # admin-announcements (5)
- # beginners (19)
- # boot (48)
- # cider (36)
- # clojure (116)
- # clojure-berlin (2)
- # clojure-italy (2)
- # clojure-japan (40)
- # clojure-russia (11)
- # clojure-sg (2)
- # clojure-spain (11)
- # clojurescript (53)
- # docs (2)
- # editors (14)
- # euroclojure (57)
- # events (2)
- # instaparse (11)
- # ldnclj (14)
- # onyx (2)
- # reading-clojure (4)
- # reagent (28)
@petrus: you can do either
The subtlety is: the component in which you do the dereference will be the component that gets rerendered when the subscription value changes.
If that rerendered component then passes updated values (from the dereference) into further child components, then they too will then be rerendered (because their props - aka parameters) changed.
This subtlety will likely be irrelevant to you, so don't sweat it too much if the above reads like double dutch.
@mikethompson: makes sense. I was worried about the rendering, yes. It feels cleaner to pass values to components, but if the root component does the deref, everything will re-render needlessly, right?
Yes, corrrect.
@petrus, @mikethompson would wrapping passed values in reaction
prevent triggering rerender?
Can you call a go routine inside a re-frame handler?
You can have a go-loop if that's what you mean
Inside the go-loop I'm doing a web request with cljs-http and when the results comes back, I want to update app-state. Should I then dispatch another event with the new, parsed data?
But remember two things:
- the normal purpose of a re-frame event handler is to provide a modified version of app-db. So this event handler, containing the go-loop will still need to return db (perhaps not modified)
- the go-loop will out-live the event handler itself. When this loop wishes to emit events, it should dispatch
them.
Great, that's what I ended up doing.
should I use register-base or one of the less pure event handlers?
Plenty of info in here: https://github.com/Day8/re-frame/wiki
You should never need to use register-base
Any good pagination stories for filtering long lists with re-frame and advancing pagination by scrolling?
I've followed the examples that use reactions to filter, but implementing discourse-style "infinite scrolling" seems like a lot more work.
Secondly, where is the right place to manage periodic polling on certain screens when using re-frame? Should I tap into dismount events for root components to stop polling?
@petrus: regarding polling, you mean you want to setup polling only if a given page/component is mounted?
@petrus: you would probably have to go with full blown component with will-mount and will-unmount to setup and bring down polling respectively
I guess I could do some of the tearup and teardown in navigation dispatches
@petrus: that feels a bit fragile to me, but maybe it could be done reliably that way - you could dispatch events that would trigger polling on certain actions
What's a clean way to deal with loading of data in re-frame when the URL route references an entity that isn't available yet?
Hm, nevermind, I think I answered my own question