resolveExitState
resolveExitState<
FC
>(transition
:undefined
|FactoryMachineTransition
<FC
["states"
]>,ev
:ResolveEvent
<FactoryMachineEvent
<FC
>>,states
:FC
["states"
]):any
Defined in: factory-machine.ts:138
Resolves the exit state for a given transition and event.
Type Parameters
Section titled “Type Parameters”Type Parameter |
---|
FC extends FactoryMachineContext <any > |
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
transition | undefined | FactoryMachineTransition <FC ["states" ]> | Transition handler or state key |
ev | ResolveEvent <FactoryMachineEvent <FC >> | The event to resolve |
states | FC ["states" ] | State factory functions |
Returns
Section titled “Returns”any
The resolved state instance or undefined
Source
Section titled “Source”This function is useful for executing transition logic and resolving the resulting state in a state machine. It supports both direct state transitions and transition handlers for flexible state management.
export function resolveExitState<FC extends FactoryMachineContext<any>>( transition: FactoryMachineTransition<FC["states"]> | undefined, ev: ResolveEvent<FactoryMachineEvent<FC>>, states: FC["states"]) { if (!transition) { return undefined; }
if (typeof transition === "function") { const stateOrFn = transition(...ev.params); return typeof stateOrFn === "function" ? (stateOrFn as any)(ev) : stateOrFn; }
return states[transition as keyof typeof states](...ev.params) as any;}