• generates a new Retry<T> instance that runs a given retryable until it successfully passes a condition

    Ex: using aftconfig.json to control conditions

    // aftconfig.json
    {
    "RetryConfig": {
    "delay": 1000,
    "backOffType": "exponential",
    "maxAttempts": 10,
    "maxDuration": 30000
    }
    }
    // in your code
    const result = await retry<number>(() => someAction()).until((res: number) => res === 5);

    console.log(result); // 5

    Ex: overriding aftconfig.json to control conditions

    // in your code
    const result = await retry<number>(() => someAction(), {
    delay: 1000,
    backOffType: 'linear',
    maxAttempts: 3,
    maxDuration: 30000,
    errorOnFail: false,
    failAction: () => doStuff()
    }).until((res: number) => res === 5);

    console.log(result); // 3 (because `maxAttempts` is 3)

    Type Parameters

    • T

    Parameters

    • retryable: Func<Retry<T>, T | PromiseLike<T>>

      the function to be retried until it passes a default condition of return value != null or a custom condition

    • Optional options: RetryOptions

      an optional RetryOptions instance allowing you to override the default settings in aftconfig.json

    Returns Retry<T>

    a new Retry<T> instance

Generated using TypeDoc