OrderProcessOptions

OrderProcessOptions

Defines custom states and transition logic for the order process state machine.

Signature

interface OrderProcessOptions<T extends string> {
  transtitions?: Partial<Transitions<T | OrderState>>;
  onTransitionStart?(
        fromState: T,
        toState: T,
        data: { order: Order },
    ): boolean | Promise<boolean> | Observable<boolean> | void;
  onTransitionEnd?(fromState: T, toState: T, data: { order: Order }): void;
  onTransitionError?(fromState: T, toState: T, message?: string): void;
}

Members

transtitions

property
type:
Partial<Transitions<T | OrderState>>

Define how the custom states fit in with the default order state transitions.

onTransitionStart

method
type:
(fromState: T, toState: T, data: { order: Order }) => boolean | Promise<boolean> | Observable<boolean> | void

Define logic to run before a state tranition takes place. Returning false will prevent the transition from going ahead.

onTransitionEnd

method
type:
(fromState: T, toState: T, data: { order: Order }) => void

Define logic to run after a state transition has taken place.

onTransitionError

method
type:
(fromState: T, toState: T, message: string) => void

Define a custom error handler function for transition errors.

alpha