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.
(cur a path)
Create a cursor.
Behaves like a normal atom for the value at the specified path.
Create a cursor. Behaves like a normal atom for the value at the specified path.
(cursor path)
(cursor path ra)
Provide a cursor into an atom.
When called with a single argument, return a function that will create a cursor given an atom.
Behaves like an atom but focuses updates and derefs to the specified path within the wrapped 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 an atom. When called with a single argument, return a function that will create a cursor given an atom. Behaves like an atom but focuses updates and derefs to the specified path within the wrapped 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