Liking cljdoc? Tell your friends :D

taia.state-machines.domain

Malli schemas for state machine data structures. Available on both JVM and ClojureScript via reader conditionals — Malli requires :clj for fn? predicates, so those are guarded.

Malli schemas for state machine data structures.
Available on both JVM and ClojureScript via reader conditionals —
Malli requires :clj for fn? predicates, so those are guarded.
raw docstring

taia.state-machines.flow

transition as a core.async flow: the same steps and invokes, without the loop. Two procs in a cycle — :machine runs step/step (pure), :invoke runs invoke/invoke-event (the side effect) — so a slow :src blocks no caller.

Messages carry the ctx (the procs keep none), so one flow serves any number of machine instances. One channel in, one out:

in [:machine :events] {:ctx :event …} sent with flow/inject out :out {:ctx :event :entered :done? …} one per microstep

Any other key of a message (an :id, a reply promise, a trace context) rides along, through the invoke and back, onto every message out.

With {:async? true} in the opts every microstep comes out, the last with :done? true; without it only that last one, the ctx transition would return. A step that throws, or a :src that throws something other than an ex-info (an ex-info is its :on-error), ends it: the last message carries the :error.

Inside, [:machine :to-invoke] → [:invoke :from-machine] carries an invoke to run, and [:invoke :to-machine] → [:machine :from-invoke] the event it raised. The :invoke proc runs each :src through its :around-invoke, if given: (fn [msg run] … (run) …), to set up a trace context, say.

Send the next event for an instance only after its :done? message: otherwise it steps from an older ctx. Needs org.clojure/core.async with flow (an optional dependency).

`transition` as a core.async flow: the same steps and invokes, without the
loop. Two procs in a cycle — :machine runs `step/step` (pure), :invoke runs
`invoke/invoke-event` (the side effect) — so a slow :src blocks no caller.

Messages carry the ctx (the procs keep none), so one flow serves any number
of machine instances. One channel in, one out:

  in  [:machine :events]  {:ctx :event …}   sent with flow/inject
  out :out                {:ctx :event :entered :done? …}   one per microstep

Any other key of a message (an :id, a reply promise, a trace context) rides
along, through the invoke and back, onto every message out.

With {:async? true} in the opts every microstep comes out, the last with
:done? true; without it only that last one, the ctx `transition` would return.
A step that throws, or a :src that throws something other than an ex-info
(an ex-info is its :on-error), ends it: the last message carries the :error.

Inside, [:machine :to-invoke] → [:invoke :from-machine] carries an invoke to
run, and [:invoke :to-machine] → [:machine :from-invoke] the event it raised.
The :invoke proc runs each :src through its :around-invoke, if given:
`(fn [msg run] … (run) …)`, to set up a trace context, say.

Send the next event for an instance only after its :done? message: otherwise
it steps from an older ctx. Needs org.clojure/core.async with flow (an
optional dependency).
raw docstring

taia.state-machines.invoke

An invoke turns its :src into an event for the state that holds it: [:on-done result], or [:on-error ex-data] when :src throws an ex-info. transition runs it when a step enters the state, and steps again with that event, handled from the invoke's :on-done / :on-error like any other event.

An invoke turns its :src into an event for the state that holds it:
[:on-done result], or [:on-error ex-data] when :src throws an ex-info.
`transition` runs it when a step enters the state, and steps again with that
event, handled from the invoke's :on-done / :on-error like any other event.
raw docstring

taia.state-machines.state

Used by the steps: where the state lives in the ctx, state paths and nodes, choosing among options, running an action.

Used by the steps: where the state lives in the ctx, state paths and nodes,
choosing among options, running an action.
raw docstring

taia.state-machines.step

One transition (a microstep), pure: from the current state, the handler for the event, its action, its target. Whether the state it entered has an invoke to run is transition's business.

One transition (a microstep), pure: from the current state, the handler for
the event, its action, its target. Whether the state it entered has an invoke
to run is `transition`'s business.
raw docstring

taia.state-machines.test-helpers

Declarative tests for hierarchical state machines: expectations map, ordered trace of action/invoke labels. Invoke :src is not run; each id uses :invoke-returns if present, else {}. Returns :ok or failure maps for RCF.

Declarative tests for hierarchical state machines: expectations map, ordered trace
of action/invoke labels. Invoke :src is not run; each id uses :invoke-returns if present,
else {}. Returns :ok or failure maps for RCF.
raw docstring

taia.state-machines.transition

transition (a macrostep): one step for the event sent; when a step enters a state with an :invoke, its :src runs here — the only side effect — and the event it raises is the next step, until a step enters no invoking state. The machine semantics end to end are in test/…/transition_test.cljc.

`transition` (a macrostep): one step for the event sent; when a step enters a
state with an :invoke, its :src runs here — the only side effect — and the event
it raises is the next step, until a step enters no invoking state. The machine
semantics end to end are in test/…/transition_test.cljc.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close