Skip to content

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.

new StateMachineValidator(machines): StateMachineValidator

Defined in: core/fsm.ts:23

ParameterType
machinesStateMachineDefinition[]

StateMachineValidator

canTransition(machineName, currentState, fromMode, toMode): boolean

Defined in: core/fsm.ts:176

Check whether a specific transition is currently valid.

ParameterType
machineNamestring
currentStateany
fromModestring | undefined
toModestring

boolean


getAllowedTransitions(machineName, currentMode): string[]

Defined in: core/fsm.ts:162

Get the list of states the current mode is allowed to transition to.

ParameterType
machineNamestring
currentModestring | undefined

string[]


getMachineNames(): string[]

Defined in: core/fsm.ts:46

Names of the configured machines.

string[]


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).

ParameterType
machineNamestring
stateany

string | undefined


getStates(machineName): string[] | undefined

Defined in: core/fsm.ts:51

Declared state names of a machine, or undefined if it isn’t configured.

ParameterType
machineNamestring

string[] | undefined


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).

ParameterType
machineNamestring
fromModestring | undefined
toModestring

Action[] | null


validateTransition(machineName, currentState, fromMode, toMode): TransitionResult

Defined in: core/fsm.ts:59

Validate a state transition and return transition details.

ParameterType
machineNamestring
currentStateany
fromModestring | undefined
toModestring

TransitionResult