Type alias OrchestrationStateConfig<TContext, TEmit, TEventTransformer>

OrchestrationStateConfig<TContext, TEmit, TEventTransformer>: {
    always?: OrchestrationTransitionConfig<TEventTransformer> | OrchestrationTransitionConfig<TEventTransformer>[];
    description?: string;
    emit?: OnOrchestrationStateEmit<TContext, TEmit> | TEmit;
    entry?: string | string[];
    eventSchema?: EventSchema<TEmit>;
    exit?: string | string[];
    initial?: string;
    on?: Record<OrchestrationMachineAllowedStringKeys, OrchestrationTransitionConfig<TEventTransformer> | OrchestrationTransitionConfig<TEventTransformer>[]>;
    onDone?: {
        target: string;
    };
    states?: Record<OrchestrationMachineAllowedStringKeys, OrchestrationStateConfig<TContext, TEmit, TEventTransformer>>;
    type?: OrchestrationStateType;
}

Configuration for an orchestration machine state.

Type Parameters

  • TContext extends Record<string, any>

  • TEmit extends string = string

  • TEventTransformer extends string | boolean = string

Type declaration

  • Optional always?: OrchestrationTransitionConfig<TEventTransformer> | OrchestrationTransitionConfig<TEventTransformer>[]

    Configuration for an abrupt state transition if this state is reached. Defines a transition to be executed whenever this state is reached, regardless of the current event.

  • Optional description?: string

    Description of the state, providing additional context or information about its purpose. This can be helpful for documentation and understanding the intended behavior of the state.

  • Optional emit?: OnOrchestrationStateEmit<TContext, TEmit> | TEmit

    Name of the function or the function to run when this state is reached. Provided in the emits key in the options of createOrchestrationMachine. These functions represent the behavior or side-effects to perform upon reaching this state.

  • Optional entry?: string | string[]

    Name(s) of the functions to run when this state is entered. Provided in the actions key in the options of createOrchestrationMachine. These functions represent the behavior or side-effects to perform upon entering this state.

  • Optional eventSchema?: EventSchema<TEmit>

    The schema of the emit this state emits. It helps in documentation

  • Optional exit?: string | string[]

    Name of the function to run when this state is exited. Provided in the actions key in the options of createOrchestrationMachine. These functions represent the behavior or side-effects to perform upon exiting this state.

  • Optional initial?: string

    Initial state if the state type is not 'parallel'. Required if the state type is not 'parallel'.

  • Optional on?: Record<OrchestrationMachineAllowedStringKeys, OrchestrationTransitionConfig<TEventTransformer> | OrchestrationTransitionConfig<TEventTransformer>[]>

    Key-value pair of events accepted by this state, with corresponding transition configurations. Defines the events that can trigger transitions from this state and the associated transition configurations.

  • Optional onDone?: {
        target: string;
    }

    Target state to go to when all parallel states are done (applicable only for 'parallel' type). Specifies the state to transition to when all parallel states under this state have completed their execution.

    • target: string
  • Optional states?: Record<OrchestrationMachineAllowedStringKeys, OrchestrationStateConfig<TContext, TEmit, TEventTransformer>>

    Nested states for parallel or final states. Allows defining sub-states for the 'parallel' or 'final' state, forming a hierarchical structure.

  • Optional type?: OrchestrationStateType

    Type of the state, either 'parallel' or 'final'. For 'parallel' type, multiple states run together simultaneously. For 'final' type, the orchestration has ended.

Example

// Example state configuration:
const stateConfig: OrchestrationStateConfig = {
type: 'parallel',
emit: ['notifyUser', 'updateStateData'],
onDone: { target: 'nextState' },
states: {
subState1: { type: 'final', emit: 'finalizeState1' },
subState2: { },
},
};

Generated using TypeDoc