Skip to content

WorkflowEvent

WorkflowEvent<Data, DebugLabel> = object & object

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

Represents a workflow event type that can be instantiated with data.

Events are the core building blocks of workflows. They define the structure of data that flows through the system and can be used to trigger handlers.

optional debugLabel: DebugLabel

Optional label used for debugging and logging purposes.

readonly uniqueId: string

Unique identifier for the event type, used for serialization and network communication.

with(data): WorkflowEventData<Data, DebugLabel>

Creates event data with the provided payload.

Data

The data payload for this event instance

WorkflowEventData<Data, DebugLabel>

Event data that can be sent through workflow contexts

include(event): event is WorkflowEventData<Data, DebugLabel>

Type guard to check if unknown event data belongs to this event type.

unknown

Unknown event data to check

event is WorkflowEventData<Data, DebugLabel>

True if the event data is of this event type

onInit(callback): Cleanup

Registers a callback to be called when this event type is instantiated.

Callback

Function to call when event is created

Cleanup

Cleanup function to remove the callback

readonly [opaqueSymbol]: DebugLabel

Data

The type of data this event can carry

DebugLabel extends string = string

Optional debug label for development/debugging

// Create an event type
const UserLoginEvent = workflowEvent<\{ userId: string; timestamp: Date \}>();
// Create event data
const loginData = UserLoginEvent.with(\{
userId: 'user123',
timestamp: new Date()
\});
// Check if data belongs to this event type
if (UserLoginEvent.include(someEventData)) \{
console.log('User ID:', someEventData.data.userId);
\}