▸ asyncPoll<T>(fn, checkFn, pollInterval?, pollTimeout?): Promise<T>
An async function that takes an async function as argument and runs it until the result satisfies a check function.
Inspired by the following gist: https://gist.github.com/douglascayers/346e061fb7c1f38da00ee98c214464ae
| Name | Description |
|---|---|
T |
The data type that will be eventually returned |
| Name | Type | Description |
|---|---|---|
fn |
Function | The main async function to call repeatedly |
checkFn |
Function | The function that takes the result of the main function to determine if polling should be stopped |
pollInterval |
number | Milliseconds to wait before attempting to resolve the promise again. |
pollTimeout |
number | Max time to keep polling to receive a successful resolved response. |
Promise<T>
A promise that will return either the desired result, an error, or timeout
index.ts:20
Ƭ AsyncPollPromiseReject: Function
▸ (reason?): void
| Name | Type |
|---|---|
reason? |
unknown |
void
index.ts:2
Ƭ AsyncPollPromiseResolve: Function
| Name |
|---|
T |
▸ (value): void
| Name | Type |
|---|---|
value |
T | PromiseLike<T> |
void
index.ts:1