This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-15
Channels
- # announcements (1)
- # beginners (101)
- # boot (13)
- # cider (38)
- # cljdoc (10)
- # cljs-dev (37)
- # cljsrn (6)
- # clojure (74)
- # clojure-dev (8)
- # clojure-europe (3)
- # clojure-italy (36)
- # clojure-losangeles (2)
- # clojure-nl (5)
- # clojure-spec (15)
- # clojure-uk (49)
- # clojuredesign-podcast (2)
- # clojurescript (52)
- # cursive (6)
- # datomic (19)
- # fulcro (35)
- # graalvm (16)
- # graphql (4)
- # kaocha (1)
- # leiningen (26)
- # luminus (3)
- # re-frame (10)
- # reagent (14)
- # ring-swagger (37)
- # rum (2)
- # schema (4)
- # shadow-cljs (148)
- # spacemacs (13)
- # specter (1)
- # sql (46)
- # tools-deps (3)
- # vim (4)
👋… 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: https://github.com/Day8/re-frame/blob/master/docs/API.md
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.