OptionalsignalName: stringOptional custom signal name (defaults to method name)
// In function-based workflow
const signals = wf.defineSignal<[string]>('updateStatus');
const cancelSignal = wf.defineSignal('cancel');
export async function orderWorkflow(): Promise<void> {
let orderStatus = 'pending';
wf.setHandler(signals, (newStatus) => {
orderStatus = newStatus;
});
wf.setHandler(cancelSignal, () => {
orderStatus = 'cancelled';
});
}
@SignalMethod('addItem')
async handleAddItem(item: OrderItem): Promise<void> {
this.orderItems.push(item);
this.recalculateTotal();
}
QueryMethod for querying workflow state
Marks a method as a signal handler for the workflow. Signals are external events that can be sent to running workflows to change their state or trigger specific behaviors. Signal methods can be asynchronous.
This decorator works in v8 isolated environments by registering signal handlers at runtime without relying on dependency injection or external services.