Skip to content

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 Parameter
FC extends FactoryMachineContext<any>
ParameterTypeDescription
transitionsFC["transitions"]Transition handlers for each state
statesFC["states"]State factory functions
evResolveEvent<FactoryMachineEvent<FC>>The event to resolve

any

The next state instance or undefined if no transition exists

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