Skip to content

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 Parameter
FC extends FactoryMachineContext<any>
ParameterTypeDescription
transitionundefined | FactoryMachineTransition<FC["states"]>Transition handler or state key
evResolveEvent<FactoryMachineEvent<FC>>The event to resolve
statesFC["states"]State factory functions

any

The resolved state instance or undefined

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;
}