Function: poll()
poll<
T>(cb: (signal:undefined|AbortSignal) =>Awaitable<T>,cbCondition: (value:Awaited<T>,signal:undefined|AbortSignal) =>Awaitable<boolean>,options:PollOptions):Promise<Awaitable<T>>
Defined in: poll.ts:41
Executes a function cb and validates the result with function cbCondition,
and repeats this until cbCondition returns true or the timeout is reached.
For a synchronous variant, see pollSync.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
cb | (signal: undefined | AbortSignal) => Awaitable<T> | The function that should be executed. |
cbCondition | (value: Awaited<T>, signal: undefined | AbortSignal) => Awaitable<boolean> | A function that when given the result of cb should return true if the polling should stop and should return false if the polling should continue. |
options | PollOptions | Options to provide further modifying behaviour. |
Returns
The result of cb as soon as cbCondition returns true, or an error if timeout is reached.
Throws
If timeout is reached.