I have a theory question related to side effects. I have a side effect that needs to wait on certain state conditions before executing. I have a queue of message that build, and then once all of the app conditions are met I want to call a external lib to show them. Normally I would look to a effect to make the js call, but I can't do that directly from everywhere I add to the queue. The two things I can think of are to either 1. Call the JS from a sub that watches the conditions. This makes the sub impure though. 2. Create a small component that subscribes to the sub and calls the js from there. This is prone to recalling the js if something else causes a re-render. I like 1, but its always painful to make something impure like that.
Not exactly what I am doing but something like
(rf/reg-sub
::show-messages
:<- [:messages]
:<- [:wizard-done]
:<- [:user-settings-api-data]
(fn [[messages wizard-done user-settings-api-data]]
(when (and messages wizard-done user-settings-api-data)
(snackbar messages user-settings-api-data))))What about a global interceptor?
A global interceptor can't reuse existing subs, but in this case that ok, because I don't need processed data, the raw db data is good.
I can see that being the right tool for sure.
Thanks.