Skip to main content

Function: pollSync()

pollSync<T>(cb: () => T, cbCondition: (value: T) => boolean, options: SyncPollOptions): T

Executes a function cb and validates the result with function cbCondition, and repeats this until cbCondition returns true or the timeout is reached.

For an asynchronous variant, see poll.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
cb() => TThe function that should be executed.
cbCondition(value: T) => booleanA function that when given the result of fn should return true if the polling should stop and should return false if the polling should continue.
optionsSyncPollOptionsOptions to provide further modifying behaviour.

Returns

T

The result of cb as soon as cbCondition returns true, or an error if timeout is reached.

Throws

If timeout is reached.

Defined in

pollSync.ts:29