Liking cljdoc? Tell your friends :D

hara.common.state


dispatchclj

(dispatch ref f & args)

Updates the value contained within a container using another thread.

(def res (state/dispatch (atom 0) (fn [x] (inc x)))) res => future? @res => atom? @@res => 1

Updates the value contained within a container using another thread.

(def res (state/dispatch (atom 0)
                         (fn [x]  (inc x))))
res   => future?
@res  => atom?
@@res => 1
raw docstring

emptyclj

(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
raw docstring

getclj

(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
raw docstring

setclj

(set obj v)
(set obj opts v)

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
raw docstring

updateclj

(update obj f)
(update obj opts? 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

raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close