Skip to content

workflowEvent

workflowEvent<Data, DebugLabel>(config?): WorkflowEvent<Data, DebugLabel>

Defined in: core/src/core/event.ts:146

Creates a new workflow event type.

This is the primary factory function for creating event types that can be used in workflows. Each event type can carry specific data and be used to trigger handlers throughout the workflow system.

Data = void

The type of data this event will carry (defaults to void)

DebugLabel extends string = string

Optional debug label type for development

WorkflowEventConfig<DebugLabel>

Optional configuration for the event type

WorkflowEvent<Data, DebugLabel>

A new workflow event type that can be instantiated with data

// Create a simple event with no data
const StartEvent = workflowEvent();
// Create an event that carries user data
const UserEvent = workflowEvent<\{ name: string; email: string \}>(\{
debugLabel: 'UserEvent'
\});
// Create event instances
const start = StartEvent.with();
const user = UserEvent.with(\{ name: 'John', email: 'john@example.com' \});