Vendure v1.0 announced! read more

Transitions

Transitions

Package: @vendure/core File: types.ts

A type which is used to define valid states and transitions for a state machine based on FSM.

Example


type LightColor = 'Green' | 'Amber' | 'Red';



const trafficLightTransitions: Transitions<LightColor> = {

  Green: {

    to: ['Amber'],

  },

  Amber: {

    to: ['Red'],

  },

  Red: {

    to: ['Green'],

  },

};

The mergeStrategy property defines how to handle the merging of states when one set of

transitions is being merged with another (as in the case of defining a {@link CustomerOrderProcess})

Signature

type Transitions<State extends string, Target extends string = State> = {
    [S in State]: {
        to: Readonly<Target[]>;
        mergeStrategy?: 'merge' | 'replace';
    };
}