Liking cljdoc? Tell your friends :D

statecharts.store

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

IStoreclj/sprotocol

get-stateclj/s

(get-state this id)

Get the current value of a state, by its id.

Get the current value of a state, by its id.

initializeclj/s

(initialize this machine opts)

Initialize a state, and save it in the store.

Initialize a state, and save it in the store.

transitionclj/s

(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-idclj/s

(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.
source

many-storeclj/s

(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))
```
sourceraw docstring

single-storeclj/s

(single-store)

A single-store stores the current value of a single state.

A single-store stores the current value of a single state.
sourceraw docstring

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

× close