🚨 Announcing Vendure v2 Beta

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) => void;
  async transitionTo(state: T, data: Data) => ;
  jumpTo(state: T) => ;
  getNextStates() => ReadonlyArray<T>;
  canTransitionTo(state: T) => boolean;
}

Members

constructor

method
type:
(config: StateMachineConfig<T, Data>, initialState: T) => FSM

initialState

property
type:
T

currentState

property
type:
T

transitionTo

method
type:
(state: T, data?: Data) => void

transitionTo

async method
type:
(state: T, data: Data) =>

jumpTo

method
type:
(state: T) =>

getNextStates

method
type:
() => ReadonlyArray<T>

canTransitionTo

method
type:
(state: T) => boolean