Optional cursor support for Reagent.
(:require [reagent.cursor :as rc])
(rc/cursor [:path :to :some :item] some-ratom)
The cursor behaves in all ways like a regular Reagent atom except that it dereferences to the specified path inside the atom and updates to it, cause updates to the atom relative to the specified path.
Optional cursor support for Reagent. (:require [reagent.cursor :as rc]) (rc/cursor [:path :to :some :item] some-ratom) The cursor behaves in all ways like a regular Reagent atom except that it dereferences to the specified path inside the atom and updates to it, cause updates to the atom relative to the specified path.
(cursor path)
(cursor path ra)
Provide a cursor into a Reagent atom.
Behaves like a Reagent atom but focuses updates and derefs to the specified path within the wrapped Reagent atom. e.g., (let [c (cursor [:nested :content] ra)] ... @c ;; equivalent to (get-in @ra [:nested :content]) ... (reset! c 42) ;; equivalent to (swap! ra assoc-in [:nested :content] 42) ... (swap! c inc) ;; equivalence to (swap! ra update-in [:nested :content] inc) )
Provide a cursor into a Reagent atom. Behaves like a Reagent atom but focuses updates and derefs to the specified path within the wrapped Reagent atom. e.g., (let [c (cursor [:nested :content] ra)] ... @c ;; equivalent to (get-in @ra [:nested :content]) ... (reset! c 42) ;; equivalent to (swap! ra assoc-in [:nested :content] 42) ... (swap! c inc) ;; equivalence to (swap! ra update-in [:nested :content] inc) )
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close