Skip to content

Instantly share code, notes, and snippets.

@borkdude
Last active Apr 12, 2022
Embed
What would you like to do?
Reagent ratom / reaction
(require '[promesa.core :as p]
'[reagent.ratom :as ratom])
(def app-state (ratom/atom {:state-var-1 {:var-a 2
:var-b 3}
:state-var-2 {:var-a 7
:var-b 9}}))
(def app-var2a-reaction (ratom/make-reaction
#(get-in @app-state [:state-var-2 :var-a])))
(defn foo []
(prn @app-var2a-reaction))
(ratom/track! foo)
(p/let [_ (p/delay 1000)]
(swap! app-state update-in [:state-var-2 :var-a] inc)
(p/delay 1000))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment