-
-
Notifications
You must be signed in to change notification settings - Fork 954
Closed
Labels
Milestone
Description
It would be nice to support the following io task in a job run:
const event = await io.waitForNextEvent("✋", { name: "opt-in", filter: { userId: [payload.userId] })We could also add a continueAfter parameter that would return undefined if the event isn't received in time:
const event = await io.waitForNextEvent("✋", {
name: "opt-in",
filter: { userId: [payload.userId] },
continueAfter: 60 * 10,
});Type Safety
Currently the event payload type in eventTrigger is inferred via an optionally passed in schema:
eventTrigger({
name: "foo.event",
schema: z.object({
userId: z.string(),
delay: z.number(),
}),
})
We could add support for a schema to waitForNextEvent as well:
const event = await io.waitForNextEvent("✋", {
name: "opt-in",
filter: { userId: [payload.userId] },
continueAfter: 60 * 10,
schema: z.object({ userId: z.string() })
});
Once we add support for an Event Catalog (#251) the event payload type would be automatically inferred based on it's name