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.
Type Parameters
Section titled “Type Parameters”Data
= void
The type of data this event will carry (defaults to void)
DebugLabel
Section titled “DebugLabel”DebugLabel
extends string
= string
Optional debug label type for development
Parameters
Section titled “Parameters”config?
Section titled “config?”WorkflowEventConfig
<DebugLabel
>
Optional configuration for the event type
Returns
Section titled “Returns”WorkflowEvent
<Data
, DebugLabel
>
A new workflow event type that can be instantiated with data
Example
Section titled “Example”// Create a simple event with no dataconst StartEvent = workflowEvent();
// Create an event that carries user dataconst UserEvent = workflowEvent<\{ name: string; email: string \}>(\{ debugLabel: 'UserEvent'\});
// Create event instancesconst start = StartEvent.with();const user = UserEvent.with(\{ name: 'John', email: 'john@example.com' \});