Starts the polling and returns a PollerUnit instance. You can track the state of polling using the PollerUnit object and cancel the polling if necessary.
| Name | Type | Description |
|---|---|---|
| options | Object | setup poller's properties |
| pollingArgs* | * | args to pass to the polling method |
The options parameter is used to configure polling. Allowed keys and default values are stated below. Note that either pollTask or pollFunction has to be present in the options object.
pollingInterval: elapsed time in ms between the completion of the last request and the next one. default: 1500
retryLimit: amount of retry attempt until timeout. If you specify retryLimit as Infinity or Number.POSITIVE_INFINITY, polling should last forever. default: 40
pollTask: the task that is to be performed on every polling attempt.
pollFunction: an async function that is to be called on every polling attempt.
- isError
:booleanreadOnlytrue if polling is failed(an exception throwed or promise rejected), false otherwise.
- isFailed
:booleanreadOnlyalias of isError
- isSuccessful
:booleanreadOnlytrue if polling is succeeded(a
truthyvalue is returned), false otherwise. - isRunning
:booleanreadOnlytrue if polling is running, meaning it is not failed, succeeded, canceled or timed out.
- isCanceled
:booleanreadOnlytrue if polling is canceled using abort() method.
- isCancelled
:booleanreadOnlyalias of isCanceled
- isTimeout
:booleanreadOnlytrue if polling terminates without success, failure and cancellation.
- retryCount
:NumberreadOnlyreturns the number of pollings made since polling started.
Cancels the ongoing polling. Upon calling this method isCancelled attribute is set to true.