This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-09
Channels
- # announcements (19)
- # babashka (26)
- # beginners (157)
- # calva (54)
- # cider (12)
- # clj-kondo (18)
- # cljdoc (3)
- # clojure (65)
- # clojure-australia (3)
- # clojure-europe (28)
- # clojure-germany (14)
- # clojure-greece (1)
- # clojure-italy (8)
- # clojure-nl (10)
- # clojure-uk (81)
- # clojuredesign-podcast (2)
- # clojurescript (20)
- # clr (1)
- # conjure (1)
- # cursive (1)
- # data-science (29)
- # datascript (2)
- # datomic (19)
- # depstar (4)
- # fulcro (24)
- # graalvm (6)
- # helix (26)
- # jobs (2)
- # jobs-discuss (2)
- # kaocha (12)
- # leiningen (1)
- # malli (17)
- # off-topic (18)
- # pathom (34)
- # polylith (23)
- # re-frame (10)
- # reagent (8)
- # releases (1)
- # remote-jobs (1)
- # reveal (5)
- # shadow-cljs (49)
- # spacemacs (1)
- # startup-in-a-month (6)
- # vim (4)
I’m having what I believe is a major misunderstanding of reactions. As far as I know, reactions should only be updating when the reactions/atoms they rely on update, but this doesn’t appear to be the case
(def a0 (r/atom {:a 0}))
(def a1 (ratom/reaction (println "proc: a1") (update @a0 :a inc)))
(def a2 (ratom/reaction (println "proc: a2") (update @a1 :a inc)))
(def a3 (ratom/reaction (println "proc: a3") (update @a2 :a inc)))
=> #'user/a0
=> #'user/a1
=> #'user/a2
=> #'user/a3
@a3
proc: a3
proc: a2
proc: a1
=> {:a 3}
@a3
proc: a3
proc: a2
proc: a1
=> {:a 3}
I expect the first deref to come up with the printlns, but I don’t expect it to the second time
This part of Reagent is not really documented, but reactions are reactive only when *ratom-context*
is set. I.e. when rendering views.
👍 3