@terminus/ngx-tools
Version:
[![CircleCI][circle-badge]][circle-link] [![codecov][codecov-badge]][codecov-project] [![semantic-release][semantic-release-badge]][semantic-release] [![MIT License][license-image]][license-url] <br> [![NPM version][npm-version-image]][npm-url] [![Github
32 lines (31 loc) • 912 B
TypeScript
import { MonoTypeOperatorFunction } from 'rxjs';
/**
* The options object that can be passed to `retryWithBackoff`
*/
export interface RetryWithBackoff {
retries: number;
delayCalculator: (attempt: number) => number;
}
/**
* Return the difference in time in words
*
* @param options - The options object
* - `retries`: How many times it should retry before throwing an error
* - `delayCalculator`: The calculator to determine the delay timing
* @returns The observable timer
*
* @example
* return this.exampleDatabase.getSomething()
* .pipe(
* map((res: MyResponse) => {
* if (res) {
* return res;
* } else {
* return null;
* }
* }),
* retryWithBackoff({}), // Using default options
* )
* ;
*/
export declare const retryWithBackoff: <T>({ retries, delayCalculator, }: Partial<RetryWithBackoff>) => MonoTypeOperatorFunction<T>;