Retries a single task up to times times, with a delay of delayms between each attempt.
times
delay
If times is zero, it repeats until it is successful
Returns when an attempt at a task is successful
// A task with a 1s timeoutconst task = Promise.race([() => getResource('foo'), new Promise((_,rej) => setTimeout(rej,1000))]);retry(() => getResource('foo').timeout(1000), 5) .then(useResource);
This will attempt to get foo up to 5 times. It will stop trying when it gets it.
foo
the Task to keep trying
the number of times to keep trying; defaults to 0 which means keep trying until successful
the number of milliseconds to wait between tries; defaults to no wait
Generated using TypeDoc
Retries a single task up to
times
times, with a delay ofdelay
ms between each attempt.If
times
is zero, it repeats until it is successfulReturns when an attempt at a task is successful
Example
This will attempt to get
foo
up to 5 times. It will stop trying when it gets it.Returns