Fork me on GitHub

👋… Does dispatch-n dispatch events synchronously? I see in the docs that they are dispatched in the order provided, and I’m assuming that means they are also synchronous?


If not, what is the recommended way of dispatching an event only after another event has completed?


There was a discussion about this some time ago.. the order simply dictates when the events are dispatched.. but if one takes longer (say an http request) the following event in your dispatch-n vector will not wait for the callback to be executed


To cope with this you might want to call your second or so event from the callback of your http request event... If you are chaining say three events that only manipulate the state I reckon those calls happen synchronously .. can anybody confirm?


Yes indeed.. if there’s no “waiting” you can rely on the order:


In my case the first event only manipulates state (sets some ids that I want to use for a graphql query), and the 2nd event makes the query using re-graph.


I see that they are dispatched in order, I just wonder if event 2 would wait for event 1 to “resolve”, or if I added a 3rd event could I rely on the fact that the re-graph query would resolve before dispatching the 3rd event.


From the re-graph docs it looks like there is a callback involved .. so I think it’s best to dispatch the event from there ..


That makes sense



🙏 4