(clone obj)
(clone obj opts)
clones the state object
(-> (state/container :volatile) (state/create 2) (state/clone)) => volatile?
clones the state object (-> (state/container :volatile) (state/create 2) (state/clone)) => volatile?
(container key)
returns the class of container given a label
(state/container :atom) => clojure.lang.Atom
(state/container :volatile) => clojure.lang.Volatile
returns the class of container given a label (state/container :atom) => clojure.lang.Atom (state/container :volatile) => clojure.lang.Volatile
(copy source sink)
(copy source sink opts)
copies the value of one state to another
(def -a- (ref nil)) (state/copy (atom 1) -a-) @-a- => 1
copies the value of one state to another (def -a- (ref nil)) (state/copy (atom 1) -a-) @-a- => 1
(create class data)
(create class data opts)
creates a state of a particular type
((juxt deref type) (state/create clojure.lang.Atom 1)) => [1 clojure.lang.Atom]
creates a state of a particular type ((juxt deref type) (state/create clojure.lang.Atom 1)) => [1 clojure.lang.Atom]
(empty obj)
(empty obj opts)
empties the state, extensible through the IStateSet protocol (let [a (atom 1)] (state/empty a) @a) => nil
empties the state, extensible through the IStateSet protocol (let [a (atom 1)] (state/empty a) @a) => nil
(get obj)
(get obj opts)
Like deref but is extensible through the IStateGet protocol
(state/get (atom 1)) => 1
(state/get (ref 1)) => 1
Like deref but is extensible through the IStateGet protocol (state/get (atom 1)) => 1 (state/get (ref 1)) => 1
(list-types)
lists all types of state-like objects
(state/list-types) ;; (:ref :promise :agent :cache :var :volatile :atom) => seq?
lists all types of state-like objects (state/list-types) ;; (:ref :promise :agent :cache :var :volatile :atom) => seq?
(set obj v)
(set obj v opts)
Like reset! but is extensible through the IStateSet protocol
(let [a (atom nil)] (state/set a 1) @a) => 1
Like reset! but is extensible through the IStateSet protocol (let [a (atom nil)] (state/set a 1) @a) => 1
(update obj f)
(update obj f & args)
Like swap! but is extensible through the IStateSet protocol
(let [a (atom 0)] (state/update a + 1) @a) => 1
Like swap! but is extensible through the IStateSet protocol (let [a (atom 0)] (state/update a + 1) @a) => 1
(update-apply obj f args)
(update-apply obj f args opts)
Like swap! but is extensible through the IStateSet protocol
(let [a (atom 0)] (state/update-apply a + [1 2 3]) @a) => 6
Like swap! but is extensible through the IStateSet protocol (let [a (atom 0)] (state/update-apply a + [1 2 3]) @a) => 6
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close