Configuration.wait()
Description
Appends a wait filter to the current pipeline layout.
A wait filter blocks all input Events up until a condition is met.
- INPUT - Any types of Events.
- OUTPUT - Same Events as the input
The condition to wait is given by the condition parameter. It should be a function that returns a truthy value when the condition is met. The function will be called every time a relevant asynchronous event happens, such as having received a response from the upstream, etc.
You can optionally set the maximum waiting time with timeout option in the options parameter. It can be a number in seconds or a string ending with one of the time unit suffixes including s, m, h and d.
This filter passes everything down unaltered. It doesn't change anything in the event stream. It only delays them.
Similarity to branch()
When branch() filter is used without a fallback branch, it has a similar effect as wait, where input events are blocked until certain condition is met. The differece is, however, branch only checks the provided condition callback when there's an input event to the filter, while wait checks it whenever any state in the context has changed.
Syntax
pipy().pipeline().wait(() => shouldContinue())pipy().pipeline().wait(() => shouldContinue(),{timeout,})
Parameters
wait(condition)
A callback function that returns true to let through input events.
The same Configuration object.