StateMachineValidator
Defined in: core/fsm.ts:20
Checks transitions against a set of machine definitions. StoreProvider
and useLocalActions build one from their stateMachines; construct one
yourself to unit-test machines or to pass to validateBindings.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new StateMachineValidator(
machines):StateMachineValidator
Defined in: core/fsm.ts:23
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
machines | StateMachineDefinition[] |
Returns
Section titled “Returns”StateMachineValidator
Methods
Section titled “Methods”canTransition()
Section titled “canTransition()”canTransition(
machineName,currentState,fromMode,toMode):boolean
Defined in: core/fsm.ts:176
Check whether a specific transition is currently valid.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
machineName | string |
currentState | any |
fromMode | string | undefined |
toMode | string |
Returns
Section titled “Returns”boolean
getAllowedTransitions()
Section titled “getAllowedTransitions()”getAllowedTransitions(
machineName,currentMode):string[]
Defined in: core/fsm.ts:162
Get the list of states the current mode is allowed to transition to.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
machineName | string |
currentMode | string | undefined |
Returns
Section titled “Returns”string[]
getMachineNames()
Section titled “getMachineNames()”getMachineNames():
string[]
Defined in: core/fsm.ts:46
Names of the configured machines.
Returns
Section titled “Returns”string[]
getMode()
Section titled “getMode()”getMode(
machineName,state):string|undefined
Defined in: core/fsm.ts:41
The machine’s current mode: state[name].mode, or the definition’s
initialState when state has no mode yet. The fallback lets a store
omit the slice (it’s created by the first transition) without an extra
commit on mount, which would also diverge between server and client
renders. A mode present in state always wins (ADR 0025).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
machineName | string |
state | any |
Returns
Section titled “Returns”string | undefined
getStates()
Section titled “getStates()”getStates(
machineName):string[] |undefined
Defined in: core/fsm.ts:51
Declared state names of a machine, or undefined if it isn’t configured.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
machineName | string |
Returns
Section titled “Returns”string[] | undefined
getTransitionHooks()
Section titled “getTransitionHooks()”getTransitionHooks(
machineName,fromMode,toMode):Action[] |null
Defined in: core/fsm.ts:147
onExit(from) + onEnter(to) without validating the transition — for
machine/force, which bypasses allowedTransitions and invariants but
must still run lifecycle hooks. Returns null if the machine or target
state doesn’t exist (an unknown from just contributes no onExit).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
machineName | string |
fromMode | string | undefined |
toMode | string |
Returns
Section titled “Returns”Action[] | null
validateTransition()
Section titled “validateTransition()”validateTransition(
machineName,currentState,fromMode,toMode):TransitionResult
Defined in: core/fsm.ts:59
Validate a state transition and return transition details.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
machineName | string |
currentState | any |
fromMode | string | undefined |
toMode | string |