Fork me on GitHub

Hi do you know public examples of idiomatic re-frame?


I want to inject subscriptions in event handler, and I am wondering if this ( is the right way to go about it. I have thought of an alternative where I take out the logic in subscriptions and put it somewhere else so that the event handler can use it (a function that takes in db and other inputs and outputs a value). But I figure that is probably not cache-friendly like how subscriptions are.


There's a third way, where you cache the value manually under some key in app-db. Global interceptors can help with that.


Note that the subscription injector you’ve linked will also cache miss if you decide to use it. IIRC there is a chance of caching when a component is already deferring the sub


There are two approaches I usually see: • if no components use the sub, bite the bullet and compute the sub — the db is always with you in an event handler • if a component uses the sub, find a way to pass the value into the event vector


Cache miss only if there are no components subscribing to it, right?


I am using this, and I am getting "Subscribe was called outside of a reactive context." warnings on js console. How do I remove this? (I have a vague sense I want to use meta for this, but not sure which)


Also, can you elaborate on using global interceptors for caching values? Would it be something like if values A or B changed, recompute C (which depends on A and B)?


Dunno about the warning, haven't looked into it. I know the reason for it but now how to suppress it. But people have asked this before, specifically in this context - maybe there's something in the issue tracker of that project or maybe you can find something in here. Regarding global interceptors - yes, exactly.

👍 2

Interceptors definitely make the implementation a lot simpler. Thanks

👍 2