Replies: 5 comments
-
This looks more like a question than a feature/bug report. I'm closing this here, but feel free to discuss it further on a better channel for discussion, e.g. Clojurians Slack, ClojureScript mailing list, Reagent mailing list. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Did this lead to any interesting discussion somewhere? I don't find much documentation on best practices for handling side effects. |
Beta Was this translation helpful? Give feedback.
-
As a general principle, side effects should always be initiated in handlers. Where there is a remote call, we have two (or three) handlers. The handler that makes the request, the handler that gets called on success, and the hanswer that gets called on error. |
Beta Was this translation helpful? Give feedback.
-
I have been wondering about this as well, it's not a very nice practice that some handlers cause side effects and some don't. Let's consider a case where I have a user using my re-frame enabled application. Sometimes there are some issues and I want to be able to log all actions that the user has made and replay them locally without any side effects (the results of side effects are still in separate actions, which I do want to replay). Now if I do not know which actions cause side effects, it is impossible to filter those out. But unless I filter them out my local instance might start to make calls to the backend with that user's session and access my browser's local storage or cookies, which in turn might make reproducing the bug impossible. I don't think this is just a theoretical discussion, but a serious concern for anyone trying to store a side effect free stream of events. I've been thinking about this for a while, and I think what I probably would want is a I haven't written a proof-of-concept yet, so not completely sure if this is the sensible way to go. I also recommend reading the related blog post, even though I think the suggested solution there results in a bit unreadable code, and I wouldn't want to go with that. |
Beta Was this translation helpful? Give feedback.
-
These are all great points, can you bring them up on the Reagent mailing list to discuss them further? |
Beta Was this translation helpful? Give feedback.
-
I have just started playing with re-frame. And I wonder: how do you replay events if your event handlers have side effects (like HTTP requests following new dispatches)?
Or maybe I am missing something?
Beta Was this translation helpful? Give feedback.
All reactions