Skip to content

Latest commit

 

History

History
93 lines (47 loc) · 3.06 KB

DSL:-AshStateMachine.md

File metadata and controls

93 lines (47 loc) · 3.06 KB

DSL: AshStateMachine

Provides tools for defining and working with resource-backed state machines.

state_machine

Nested DSLs

Options

Name Type Default Docs
initial_states{: #state_machine-initial_states .spark-required} list(atom) The allowed starting states of this state machine.
deprecated_states{: #state_machine-deprecated_states } list(atom) [] A list of states that have been deprecated but are still valid. These will still be in the possible list of states, but :* will not include them.
extra_states{: #state_machine-extra_states } list(atom) [] A list of states that may be used by transitions to/from :*. See the docs on wildcards for more.
state_attribute{: #state_machine-state_attribute } atom :state The attribute to store the state in.
default_initial_state{: #state_machine-default_initial_state } atom The default initial state

state_machine.transitions

Wildcards

Use :* to represent "any action" when used in place of an action, or "any state" when used in place of a state.

For example:

transition :*, from: :*, to: :*

The full list of states is derived at compile time from the transitions. Use the extra_states to express that certain types should be included in that list even though no transitions go to/from that state explicitly. This is necessary for cases where there are states that use :* and no transition explicitly leads to that transition.

Nested DSLs

state_machine.transitions.transition

transition action

Arguments

Name Type Default Docs
action{: #state_machine-transitions-transition-action .spark-required} atom The corresponding action that is invoked for the transition. Use :* to allow any update action to perform this transition.

Options

Name Type Default Docs
from{: #state_machine-transitions-transition-from .spark-required} list(atom) | atom The states in which this action may be called. If not specified, then any state is accepted. Use :* to refer to all states.
to{: #state_machine-transitions-transition-to .spark-required} list(atom) | atom The states that this action may move to. If not specified, then any state is accepted. Use :* to refer to all states.

Introspection

Target: AshStateMachine.Transition

<style type="text/css">.spark-required::after { content: "*"; color: red !important; }</style>