You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/workflows/build/workers-api.mdx
+34-10Lines changed: 34 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -112,8 +112,21 @@ More information about the limits imposed on Workflow can be found in the [Workf
112
112
*`name` - the name of the step.
113
113
*`options` - an object with properties for `type`, which determines which event type this `waitForEvent` call will match on when calling `instance.sendEvent`, and an optional `timeout` property, which defines how long the `waitForEvent` call will block for before throwing a timeout exception. The default timeout is 24 hours.
114
114
115
-
Review the documentation on [events and parameters](/workflows/build/events-and-parameters/) to learn how to send events to a running Workflow instance.
let event =awaitstep.waitForEvent<IncomingStripeWebhook>("receive invoice paid webhook from Stripe", { type: "stripe-webhook", timeout: "1 hour" })
122
+
// Rest of your Workflow
123
+
}
124
+
}
125
+
```
116
126
127
+
</TypeScriptExample>
128
+
129
+
Review the documentation on [events and parameters](/workflows/build/events-and-parameters/) to learn how to send events to a running Workflow instance.
117
130
118
131
## WorkflowStepConfig
119
132
@@ -414,28 +427,39 @@ Terminate a Workflow instance.
414
427
415
428
### sendEvent
416
429
417
-
[Send an event]() to a running Workflow instance.
430
+
[Send an event](/workflows/build/events-and-parameters/) to a running Workflow instance.
418
431
419
432
* <code>sendEvent(): Promise<void></code>
420
433
421
-
*`options` - the event `type` and `payload` to send to the Workflow instance. The `type` must match the `type` in
434
+
*`options` - the event `type` and `payload` to send to the Workflow instance. The `type` must match the `type` in the corresponding `waitForEvent` call in your Workflow.
422
435
423
436
Return `void` on success; throws an exception if the Workflow is not running or is an errored state.
You can call `sendEvent` multiple times, setting the value of the `type` property to match the specific `waitForEvent` calls in your Workflow.
461
+
462
+
This allows you to wait for multiple events at once, or use `Promise.race` to wait for multiple events and allow the first event to progress the Workflow.
0 commit comments