resolveNextState
resolveNextState<
FC
>(transitions
:FC
["transitions"
],states
:FC
["states"
],ev
:ResolveEvent
<FactoryMachineEvent
<FC
>>):any
Defined in: factory-machine.ts:119
Resolves the next state for a given event using the provided transitions and states.
Type Parameters
Section titled “Type Parameters”Type Parameter |
---|
FC extends FactoryMachineContext <any > |
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
transitions | FC ["transitions" ] | Transition handlers for each state |
states | FC ["states" ] | State factory functions |
ev | ResolveEvent <FactoryMachineEvent <FC >> | The event to resolve |
Returns
Section titled “Returns”any
The next state instance or undefined if no transition exists
Source
Section titled “Source”This function is useful for determining the next state in a state machine based on the current state, event, and transition handlers. It enables dynamic state resolution and transition logic.
export function resolveNextState<FC extends FactoryMachineContext<any>>( transitions: FC["transitions"], states: FC["states"], ev: ResolveEvent<FactoryMachineEvent<FC>>) { const transition = transitions[ev.from.key]?.[ev.type]; return resolveExitState(transition, ev, states);}