(actor-send! [actor message])
Sends message to xstate actor
Sends message to xstate actor
(actor-start! {:keys [actor]})
Starts xstate actor.
Starts xstate actor.
(actor-subscribe! {:keys [actor] {:keys [id]} :config})
Adds a listener to the actor to listen to state changes.
Adds a listener to the actor to listen to state changes.
(evt->edn evt)
Converts the xstate event object to edn.
Converts the xstate event object to edn.
(get-fsm db [_ fsm-id])
Returns the FSM by id from db.
Returns the FSM by id from db.
(get-fsm-actor db [_ fsm-id])
Returns the xstate actor of the FSM from db.
Returns the xstate actor of the FSM from db.
(get-fsm-config db [_ fsm-id])
Returns the config of the FSM from db.
Returns the config of the FSM from db.
(get-fsm-context db [_ fsm-id])
Returns the context of the FSM from db.
Returns the context of the FSM from db.
(get-fsm-machine db [_ fsm-id])
Returns the xstate machine of the FSM from db.
Returns the xstate machine of the FSM from db.
(get-fsm-state db [_ fsm-id])
Returns the current state as a js object (returned by XState) of the FSM from db.
Returns the current state as a js object (returned by XState) of the FSM from db.
(get-fsm-state-map db [_ fsm-id])
Returns the current state as a clojure map from db.
Returns the current state as a clojure map from db.
(initialize-fsm {:keys [db]} [{:keys [id context] :as fsm-config} fsm-options])
Initializes the FSM and updates the db with the FSM map.
Initializes the FSM and updates the db with the FSM map.
(normalize-actions actions)
Normalizes the actions by converting the type to a keyword.
Normalizes the actions by converting the type to a keyword.
(on-state fsm-id)
Xstate actor subscribe listener, dispatches ::update-state
event
Xstate actor subscribe listener, dispatches `::update-state` event
(run-effectful-action! [effect evt])
Runs the effectful action function, given the event.
Runs the effectful action function, given the event.
(send {:keys [db]} [fsm-id {:keys [type] :as message}])
Dispatches an effect to send a message to a xstate actor.
fsm-id
, transition-actions
and ctx
are injected to the message.
Dispatches an effect to send a message to a xstate actor. `fsm-id`, `transition-actions` and `ctx` are injected to the message.
(transition db [_ fsm-id state message])
Returns the new state given app-db, fsm-id, current state, and message
Returns the new state given app-db, fsm-id, current state, and message
(transition-params action-id transition-actions)
Returns the params for the given action-id in the transition-actions property that's injected from
the send
event into the message.
Returns the params for the given action-id in the transition-actions property that's injected from the `send` event into the message.
(update-context {:keys [db]} [{:keys [fsm-id] :as evt} action-fn])
Given a ctx-action function and an event, updates the context of the FSM in the db. This is used instead of the default xstate context updating, because the default xstate context updating doesn't work with re-frame subscriptions, and converting from edn to json and back results in a loss of data.
Given a ctx-action function and an event, updates the context of the FSM in the db. This is used instead of the default xstate context updating, because the default xstate context updating doesn't work with re-frame subscriptions, and converting from edn to json and back results in a loss of data.
(update-state {:keys [db]} [fsm-id state])
Updates the state of the FSM in the db. Dispatches action events on transition if any.
Updates the state of the FSM in the db. Dispatches action events on transition if any.
(wrap-ctx-action action-fn)
Given a context action function, returns a 2-arity callback that can be used as an xstate action. The event is converted to edn before being passed to the action function.
Given a context action function, returns a 2-arity callback that can be used as an xstate action. The event is converted to edn before being passed to the action function.
(wrap-effectful-action action-fn)
Given an effectful action function, returns a 2-arity callback that can be used as an xstate action. The event is converted to edn before being passed to the action function.
Given an effectful action function, returns a 2-arity callback that can be used as an xstate action. The event is converted to edn before being passed to the action function.
(wrap-guard guard-fn)
Given a function that takes an event and returns a boolean, returns a 2-arity callback that can be used as an xstate guard. The event is converted to edn before being passed to the guard function.
Given a function that takes an event and returns a boolean, returns a 2-arity callback that can be used as an xstate guard. The event is converted to edn before being passed to the guard function.
(xstate-state->clj state)
Returns the xstate state object as a clojure map.
Returns the xstate state object as a clojure map.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close