This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-08-19
Channels
- # admin-announcements (14)
- # architecture (1)
- # beginners (21)
- # boot (301)
- # clojure (93)
- # clojure-brasil (56)
- # clojure-india (4)
- # clojure-italy (11)
- # clojure-japan (25)
- # clojure-russia (16)
- # clojure-sg (1)
- # clojure-uk (5)
- # clojurescript (64)
- # clojurex (4)
- # clojutre (7)
- # cursive (18)
- # datascript (35)
- # datomic (212)
- # editors (27)
- # emacs (38)
- # events (9)
- # funcool (21)
- # hoplon (105)
- # jobs (2)
- # ldnclj (41)
- # ldnproclodo (4)
- # liberator (89)
- # luminus (5)
- # off-topic (32)
- # om (39)
- # onyx (1)
- # re-frame (9)
- # reactive (1)
- # reagent (34)
- # testing (42)
- # yada (4)
Hey, if I have a handler that looks something like this:
(defn my-handler [db [_ new-value]]
(re-frame/dispatch [:something])
(assoc db :breakfast new-value))
…can I assume in the body of the :something
handler that (:breakfast db)
will equal new-value
? Or is it non-deterministic whether the :something
handler or the (assoc)
will be executed first, because of asynchrony?I’m pretty sure that the dispatch won’t be run until the current handler has completed
I had a similar question yesterday
If you decided to park inside a handler in a core.async go block then all bets are off though
Well, dispatch is going to be called because it's just a function. Inside dispatch :something
is going to be put!
onto the event-chan
. Since there is no matching reader at the moment that happens, the put!
won't take place immediately and will be queued up and the call to dispatch
will return, the rest of your handler code will get executed, and then at some point in the future the value that you dispatched will get handled.
Cool, thanks for the explanations everyone
@meow: even if there was a matching reader I wouldn’t expect that part to be run until the current handler had finished.