Fork me on GitHub
#re-frame
<
2017-04-14
>
danielcompton00:04:33

@mattly 2 things: 1. Subscriptions are cached, and multiple calls for a sub with the same params will return the same Reaction instance. They are disposed of when they are no longer referenced, so if Reagent doesn't see the sub being used, it will dispose of it. 2. Make sure that your subscription isn't pulling directly off the root, otherwise Reagent will see the panel change in app-db as a change that needs to cause the subscription to rerun (even though the keys used by that subscription haven't changed)

mikethompson02:04:26

@mattly to follow on from Daniel's point ... be sure to use the 4 layer model to avoid unnecessary re-computation (layer 2 is key in that): https://github.com/Day8/re-frame/blob/master/docs/SubscriptionInfographic.md

mattly02:04:16

aha, thanks

jfntn20:04:09

Had a question w.r.t. testing handlers. One approach I didn’t see mentioned in the docs is to have a config map of event-keywords to handler-fns. If you never use reg-sub etc outside of a couple of side-effectful start/stop fns that take a config and do registration, you should be able to specify exactly which handlers run just by selecting keys in the config, or updating it to inject mocks/stubs. Has anyone tried that? Are there any issues I’m missing here?