In the re-frame docs (http://day8.github.io/re-frame/Effects/) it refers to "`re-frame's` built-in effect handlers, like `dispatch-n` and `dispatch-later`, are detailed in https://day8.github.io/re-frame/codox/ document." But on that page I see defined only dispatch
and dispatch-sync
. What am I missing?
Actually I am not sure that codox page is working. None of the links do anything for me (Chrome 84, macOS 10.14.6)
I'm trying to remember how one should dispatch events from an event handler. I suspect using dispatch-async
directly is counter-indicated and you should be using reg-event-fx
and having something else trigger the dispatch but I can't seem to find it in the docs.
Found it, in the Effects: Two Step Plan section, returning {:dispatch […]}
It seems like either {:dispatch []}
is an example not implemented or there is magic functionality that makes it work not documented. For example if I want do dispatch two events as a side-effect, can I :dispatch [[evt1][evt2]]
?
Okay have found what I need in fx.cljc
@sandbags Sorry, that link on that page is old and wrong (now corrected). This is the link you should be using ... https://day8.github.io/re-frame/api/#api-builtin-effects.html
It seems like you might want effects like this:
{ :db (assoc db :something :else)
:dispatch-n (list [:first-event] [:second-event "yeah"])}
^^^ note that's :dispatch-n
and not :dispatch
Thanks @mikethompson I eventually ended up spelunking into fx.cljc but grateful for the confirmation. I've been away from re-frame too long!
Glad to have you back :-)
In our project, our views.cljs is growing pretty fast, are there any patterns or naming conventions for moving to a views folder then having files for each page or group of components?
I usually write a namespace for components that will work together. Similar to the hexagonal architecture.
Okay, I'll bite. Hexagonal architecture is a new one on me… where can I find out more?
It just means that you will write many fully qualified events and subs, and only few of them will be global and shared.
I had heard of this in another context, is it the same? https://netflixtechblog.com/ready-for-changes-with-hexagonal-architecture-b315ec967749