FSM
FSM
A simple type-safe finite state machine. This is used internally to control the Order process, ensuring that the state of Orders, Payments, Fulfillments and Refunds follows a well-defined behaviour.
Signature
class FSM<T extends string, Data = any> {
constructor(config: StateMachineConfig<T, Data>, initialState: T)
initialState: T
currentState: T
transitionTo(state: T, data: Data) => Promise<{ finalize: () => Promise<any> }>;
jumpTo(state: T) => ;
getNextStates() => readonly T[];
canTransitionTo(state: T) => boolean;
}
constructor
method
(config: StateMachineConfig<T, Data>, initialState: T) => FSM
initialState
property
T
currentState
property
T
transitionTo
method
(state: T, data: Data) => Promise<{ finalize: () => Promise<any> }>
jumpTo
method
(state: T) =>
getNextStates
method
() => readonly T[]
canTransitionTo
method
(state: T) => boolean