Skip to main content

Interface: ChildWorkflowHandle<T>

workflow.ChildWorkflowHandle

A client side handle to a single Workflow instance. It can be used to start, signal, wait for completion, and cancel a Workflow execution.

Given the following Workflow definition:

export const incrementSignal = defineSignal('increment');export async function counterWorkflow(initialValue: number): Promise<void>;

Create a handle for running and interacting with a single Workflow:

const handle = createChildWorkflowHandle(counterWorkflow);// Start the Workflow with initialValue of 2.await handle.start(2);await handle.signal(incrementSignal, 2);await handle.result(); // throws WorkflowExecutionTerminatedError

Type parameters#

NameType
Textends Workflow

Hierarchy#

Properties#

workflowId#

Readonly workflowId: string

The workflowId of the current Workflow

Inherited from#

BaseWorkflowHandle.workflowId

Methods#

execute#

execute(...args): Promise<WorkflowResultType<T>>

Start the Workflow with arguments, returns a Promise that resolves when the Workflow execution completes

Parameters#

NameType
...argsParameters<T>

Returns#

Promise<WorkflowResultType<T>>

Inherited from#

BaseWorkflowHandle.execute


result#

result(): Promise<WorkflowResultType<T>>

Promise that resolves when Workflow execution completes

Returns#

Promise<WorkflowResultType<T>>

Inherited from#

BaseWorkflowHandle.result


signal#

signal<Args>(def, ...args): Promise<void>

Signal a running Workflow.

example

await handle.signal(incrementSignal, 3);

Type parameters#

NameType
Argsextends any[][]

Parameters#

NameTypeDescription
defstring | SignalDefinition<Args>a signal definition as returned from defineSignal
...argsArgs-

Returns#

Promise<void>

Inherited from#

BaseWorkflowHandle.signal


start#

start(...args): Promise<string>

Start the Workflow with arguments, returns a Promise that resolves with the execution runId

Parameters#

NameType
...argsParameters<T>

Returns#

Promise<string>

Inherited from#

BaseWorkflowHandle.start