Hi, just trying to grok reframe, some Qs: 1. Are all handlers just some kind of interceptor? 2. Is the only difference between the cofx and the fx the convention that the cofx comes before the event handler, and the fx comes afterwards? 3. Is it good practice to handle async operations (such as http fetch requests) through reframe fx?
Yes, you are correct.
tyvm :]
1. Handlers are functions, but internally in re-frame they're wrapped with an interceptor that calls them. The impl is pretty straightforward to follow
2. I'd say it's the reverse, in a way - the only common thing between cofx and fx is that they're both maps with keyword keys. And the cofx map has the :db key, while the fx map might or might not have it
3. Yes
Thank you @p-himik,
If the :db effect is not created in the context map, this means that :db stays the same, correct?
I was wondering if this might mean that :db is emptied, but it seems that the lack of :db means that the underlying atom (`ratom`?) that holds the data will simply not be reset! .
per line: https://github.com/day8/re-frame/blob/1ed85ebae9bd611cfc97b2b66e8df9969f672616/src/re_frame/fx.cljc#L55
(seems some questions are better answered by the code than the docs)
However, when using reg-event-db this does not hold true, returning nothing would create a nil value that gets stored in the :db key.
per line: https://github.com/day8/re-frame/blob/1ed85ebae9bd611cfc97b2b66e8df9969f672616/src/re_frame/std_interceptors.cljc#L96
Seems correct? Hopefully I am finally getting it.