This namespace provides an interface for a mutable datastore for one or more states.
It is used in places that are concerned with storing states as they change over
time. So, statecharts.service
, which notifies listeners when a state
changes, and statecharts.integrations.re-frame
, which persists state changes
in a re-frame app-db, both use it. It is also used in statecharts.scheduler
,
which is concerned with scheduling state changes that will happen at some future
time.
This namespace provides an interface for a mutable datastore for one or more states. It is used in places that are concerned with storing states as they change _over time_. So, [[statecharts.service]], which notifies listeners when a state changes, and [[statecharts.integrations.re-frame]], which persists state changes in a re-frame app-db, both use it. It is also used in [[statecharts.scheduler]], which is concerned with scheduling state changes that will happen at some future time.
(get-state this id)
Get the current value of a state, by its id.
Get the current value of a state, by its id.
(initialize this machine opts)
Initialize a state, and save it in the store.
Initialize a state, and save it in the store.
(transition this machine state event opts)
Transition a state previously saved in the store. Save and return its new value.
Transition a state previously saved in the store. Save and return its new value.
(unique-id this state)
Get the id that the store uses to identify this state.
Get the id that the store uses to identify this state.
(many-store)
(many-store {:keys [id] :or {id :id}})
A many-store stores the current values of many states.
The opts
provided to init
should configure the state to have a unique id.
This ensures that the state can be identified and transitioned later, by both
external and scheduled events.
By default, a many-store expects the id to be :id
.
(let [store (store/many-store)]
(store/initialize store fsm {:context {:id 1}})
(store/get-state store 1))
The id can be configured by providing an :id
key in the many-store
configuration options.
(let [store (store/many-store {:id :my-id})]
(store/initialize store fsm {:context {:my-id 1}})
(store/get-state store 1))
A many-store stores the current values of many states. The `opts` provided to `init` should configure the state to have a unique id. This ensures that the state can be identified and transitioned later, by both external and scheduled events. By default, a many-store expects the id to be `:id`. ```clojure (let [store (store/many-store)] (store/initialize store fsm {:context {:id 1}}) (store/get-state store 1)) ``` The id can be configured by providing an `:id` key in the many-store configuration options. ```clojure (let [store (store/many-store {:id :my-id})] (store/initialize store fsm {:context {:my-id 1}}) (store/get-state store 1)) ```
(single-store)
A single-store stores the current value of a single state.
A single-store stores the current value of a single state.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close