Type alias OnOrchestrationStateEmit<TContext, TEmit, ReturnType>

OnOrchestrationStateEmit<TContext, TEmit, ReturnType>: ((id, state, snapshot) => ReturnType)

Middleware function type for handling orchestration logic based on state and snapshot data. This function takes the current state and a machine snapshot, and returns data to create a CloudEvent representing the necessary actions or information for cloud-based orchestration.

Type Parameters

Type declaration

    • (id, state, snapshot): ReturnType
    • Parameters

      • id: string

        The unique identifier for the orchestration actor.

      • state: string

        The current state of the machine.

      • snapshot: MachineSnapshot<TContext, any, any, any, any, any, any>

        The snapshot of the machine, providing a detailed view of its current state.

      Returns ReturnType

Returns

An object containing the type of the event, and optionally, additional data. The type ideally must be the topic of the event e.g. cmd.books.fetch, evt.books.fetch.success, notif.orch.done. This is then converted to a CloudEvent to emit

Example

// Example middleware function for handling orchestration based on state and snapshot.
const onOrchestrationState: OnOrchestrationState = (id, state, snapshot) => {
return {
type: 'evt.books.fetch.success',
data: { orchestrationId: id, status: 'completed', snapshot },
};
};

Generated using TypeDoc