Skip to content

WorkflowContext

WorkflowContext = object

Defined in: core/src/core/context.ts:91

Execution context for workflow event processing.

The workflow context provides the runtime environment for executing handlers and managing event flow. It offers access to the event stream, abort signals, and methods for sending events within the workflow.

// Use the current context (first parameter inside a handler)
const \{ sendEvent, stream, signal \} = context;
// Send events
sendEvent(
ProcessEvent.with(\{ step: 'validation' \}),
LogEvent.with(\{ message: 'Processing started' \})
);
// Access the event stream
await stream.filter(CompletionEvent).take(1).toArray();
// Check for cancellation
if (signal.aborted) \{
throw new Error('Operation cancelled');
\}

sendEvent: (…events) => void

Defined in: core/src/core/context.ts:110

Sends one or more events into the workflow for processing. Events will be delivered to all matching handlers asynchronously.

WorkflowEventData<any>[]

Event data instances to send

void


__internal__call_send_event: Subscribable<[WorkflowEventData<any>, HandlerContext], void>

Defined in: core/src/core/context.ts:119


__internal__property_inheritance_handlers?

Section titled “__internal__property_inheritance_handlers?”

optional __internal__property_inheritance_handlers: Map<string, InheritanceTransformer>

Defined in: core/src/core/context.ts:123

get stream(): WorkflowStream<WorkflowEventData<any>>

Defined in: core/src/core/context.ts:96

Stream of all events flowing through this workflow context. Can be used to listen for specific events or create reactive processing chains.

WorkflowStream<WorkflowEventData<any>>


get signal(): AbortSignal

Defined in: core/src/core/context.ts:102

Abort signal that indicates if the workflow has been cancelled. Handlers should check this periodically for long-running operations.

AbortSignal