Function: UpdateMethod()
UpdateMethod(
updateName?):MethodDecorator
Defined in: src/decorators/workflow.decorator.ts:302
Marks a method as an update handler for the workflow. Updates are synchronous-style requests that can both mutate workflow state and return a result to the caller, combining the strengths of Signals (can mutate state) and Queries (can return a result) into a single request/response operation.
This decorator works in v8 isolated environments by registering update handlers at runtime without relying on dependency injection or external services.
Parameters
updateName?
string
Optional custom update name (defaults to method name)
Returns
MethodDecorator
Examples
Basic Update Handler
// In function-based workflow
const incrementAndGetValueUpdate = wf.defineUpdate<number, [number]>('incrementAndGetValue');
export async function counterWorkflow(initialValue: number): Promise<void> {
let value = initialValue;
wf.setHandler(incrementAndGetValueUpdate, (increment: number) => {
value += increment;
return value;
});
}
Update with Complex Data
@UpdateMethod('approveOrder')
async handleApproval(approval: OrderApproval): Promise<OrderStatus> {
this.approvals.push(approval);
return this.currentStatus;
}
See
- SignalMethod for fire-and-forget mutations
- QueryMethod for read-only state access