(cursor ref selector)
(cursor ref selector key)
adds a cursor to the atom to update on any change
(def a (atom {:a {:b 1}}))
(def ca (cursor a [:a :b]))
(do (swap! ca + 10) (swap! a update-in [:a :b] + 100) [(deref a) (deref ca)]) => [{:a {:b 111}} 111]
adds a cursor to the atom to update on any change (def a (atom {:a {:b 1}})) (def ca (cursor a [:a :b])) (do (swap! ca + 10) (swap! a update-in [:a :b] + 100) [(deref a) (deref ca)]) => [{:a {:b 111}} 111]
(derived atoms f)
(derived atoms f key)
constructs an atom derived from other atoms
(def a (atom 1)) (def b (atom 10)) (def c (derived [a b] +))
(do (swap! a + 1) (swap! b + 10) [@a @b @c]) => [2 20 22]
constructs an atom derived from other atoms (def a (atom 1)) (def b (atom 10)) (def c (derived [a b] +)) (do (swap! a + 1) (swap! b + 10) [@a @b @c]) => [2 20 22]
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close