1 | import { CancelOptions } from './types';
|
2 | interface RetryerConfig<TData = unknown, TError = unknown> {
|
3 | fn: () => TData | Promise<TData>;
|
4 | abort?: () => void;
|
5 | onError?: (error: TError) => void;
|
6 | onSuccess?: (data: TData) => void;
|
7 | onFail?: (failureCount: number, error: TError) => void;
|
8 | onPause?: () => void;
|
9 | onContinue?: () => void;
|
10 | retry?: RetryValue<TError>;
|
11 | retryDelay?: RetryDelayValue<TError>;
|
12 | }
|
13 | export declare type RetryValue<TError> = boolean | number | ShouldRetryFunction<TError>;
|
14 | declare type ShouldRetryFunction<TError = unknown> = (failureCount: number, error: TError) => boolean;
|
15 | export declare type RetryDelayValue<TError> = number | RetryDelayFunction<TError>;
|
16 | declare type RetryDelayFunction<TError = unknown> = (failureCount: number, error: TError) => number;
|
17 | interface Cancelable {
|
18 | cancel(): void;
|
19 | }
|
20 | export declare function isCancelable(value: any): value is Cancelable;
|
21 | export declare class CancelledError {
|
22 | revert?: boolean;
|
23 | silent?: boolean;
|
24 | constructor(options?: CancelOptions);
|
25 | }
|
26 | export declare function isCancelledError(value: any): value is CancelledError;
|
27 | export declare class Retryer<TData = unknown, TError = unknown> {
|
28 | cancel: (options?: CancelOptions) => void;
|
29 | cancelRetry: () => void;
|
30 | continueRetry: () => void;
|
31 | continue: () => void;
|
32 | failureCount: number;
|
33 | isPaused: boolean;
|
34 | isResolved: boolean;
|
35 | isTransportCancelable: boolean;
|
36 | promise: Promise<TData>;
|
37 | private abort?;
|
38 | constructor(config: RetryerConfig<TData, TError>);
|
39 | }
|
40 | export {};
|