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.
Type Declaration
Section titled “Type Declaration”debugLabel?
Section titled “debugLabel?”
optional
debugLabel:DebugLabel
Optional label used for debugging and logging purposes.
uniqueId
Section titled “uniqueId”
readonly
uniqueId:string
Unique identifier for the event type, used for serialization and network communication.
with()
Section titled “with()”with(
data
):WorkflowEventData
<Data
,DebugLabel
>
Creates event data with the provided payload.
Parameters
Section titled “Parameters”Data
The data payload for this event instance
Returns
Section titled “Returns”WorkflowEventData
<Data
, DebugLabel
>
Event data that can be sent through workflow contexts
include()
Section titled “include()”include(
event
):event is WorkflowEventData<Data, DebugLabel>
Type guard to check if unknown event data belongs to this event type.
Parameters
Section titled “Parameters”unknown
Unknown event data to check
Returns
Section titled “Returns”event is WorkflowEventData<Data, DebugLabel>
True if the event data is of this event type
onInit()
Section titled “onInit()”onInit(
callback
):Cleanup
Registers a callback to be called when this event type is instantiated.
Parameters
Section titled “Parameters”callback
Section titled “callback”Callback
Function to call when event is created
Returns
Section titled “Returns”Cleanup
Cleanup function to remove the callback
Type Declaration
Section titled “Type Declaration”[opaqueSymbol]
Section titled “[opaqueSymbol]”
readonly
[opaqueSymbol]:DebugLabel
Type Parameters
Section titled “Type Parameters”Data
The type of data this event can carry
DebugLabel
Section titled “DebugLabel”DebugLabel
extends string
= string
Optional debug label for development/debugging
Example
Section titled “Example”// Create an event typeconst UserLoginEvent = workflowEvent<\{ userId: string; timestamp: Date \}>();
// Create event dataconst loginData = UserLoginEvent.with(\{ userId: 'user123', timestamp: new Date()\});
// Check if data belongs to this event typeif (UserLoginEvent.include(someEventData)) \{ console.log('User ID:', someEventData.data.userId);\}