Skip to content

Recommendations on waiting for a condition to happen #1931

Answered by tonyhb
jasonroelofs asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @jasonroelofs - yes, this is exactly what step.waitForEvent is for. It'll pause your function, set up a new signal, and automatically resolve whenever the matching event is found.

If you then instrument other parts of your app with events (free our side, and a low implementation cost) you'll automatically resume those functions.

Typically, it'd be something like this:

await step.waitForEvent("some-step-id", {
  event: "api/something.happened", // format: <service>/<noun>
  timeout: "12h",
  if: `async.data.completion_id == "${someVar}"`,
});

You probably want to store some sort of ID for the matching expression. Without more details, it's hard to know what identifiers you can use to r…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jasonroelofs
Comment options

Answer selected by jasonroelofs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants