This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-09
Channels
- # beginners (121)
- # boot (28)
- # cider (106)
- # clara (57)
- # cljs-dev (70)
- # cljsrn (6)
- # clojure (145)
- # clojure-dev (7)
- # clojure-italy (36)
- # clojure-russia (42)
- # clojure-spec (26)
- # clojure-uk (127)
- # clojurescript (103)
- # core-async (10)
- # cursive (56)
- # datascript (66)
- # datomic (16)
- # defnpodcast (1)
- # emacs (18)
- # events (6)
- # figwheel (1)
- # jobs (1)
- # luminus (1)
- # lumo (44)
- # off-topic (58)
- # om (17)
- # onyx (2)
- # parinfer (75)
- # pedestal (4)
- # re-frame (18)
- # ring (4)
- # ring-swagger (8)
- # rum (7)
- # spacemacs (7)
- # specter (2)
- # sql (4)
- # unrepl (39)
- # untangled (17)
- # vim (3)
- # yada (21)
What is a good way to execute some function whenever a subscription changes to a certain value?
r/track!
the other way would be to create a Form-3 component which dereferences the subscription, with a component-did-update lifecycle method. I think a component's did-update will fire when a watched atom changes.
a thing to be aware of is that adding side effects to state changes is frowned upon by some
I see, good point
The rules of the game for experiments are different
r/track! is your friend then, it works nicely
I guess you'll still need to create the track! inside a lifecycle method
you're welcome 🙂
This worked:
(defn foo []
(let [done? @(subscribe [::subs/widgets-done?])]
(when done? (js/alert “done!“))))
(r/track! foo)
heh, yeah running it as a top level form would work too 🙂