Fork me on GitHub
#re-frame
<
2016-12-23
>
mikethompson02:12:19

@vikeri At its core, re-frame is event driven. When an event happens, it is processed by event handlers. Later, there is a reactive process by which the UI is updated. It sounds to me like you want to use the reactive process (subscriptions) to do something imperative? Or maybe a further dispatch. Have I understood?

mikethompson02:12:18

Are you seeking to know when X happens so you can then do Y. Is it like that?

vikeri08:12:59

@mikethompson That is correct! I want to schedule a notification based on the updated reaction. I could add a listener to the re-frame event, but then I’d have to redo all the logic that is now in my subscription handlers, it would be much easier to just monitor my subscriptions with add-watch. It’s just funny that add-watch works as intended if I’m also referring to the same subscription in a component.

vikeri09:12:32

Apparently reagent.core/track! was the solution 🎉

curlyfry09:12:44

@vikeri Cool, how did you end up using it?

vikeri09:12:00

@curlyfry Super simple, just wrote a function observer-fn that dereffed a subscription and then (r/track! observer-fn). Then each time the subscription updates the function will be rerun. B-E-A-utiful