backOff<T> function

Future<T> backOff<T>(
  1. FutureOr<T> func(), {
  2. Duration delayFactor = const Duration(milliseconds: 200),
  3. double randomizationFactor = 0.25,
  4. Duration maxDelay = const Duration(seconds: 30),
  5. int maxAttempts = 8,
  6. FutureOr<bool> retryIf(
    1. Object error,
    2. int attempt
    )?,
})

TopLevel lambda to apply BackOff to functions.

Implementation

Future<T> backOff<T>(
  FutureOr<T> Function() func, {
  Duration delayFactor = const Duration(milliseconds: 200),
  double randomizationFactor = 0.25,
  Duration maxDelay = const Duration(seconds: 30),
  int maxAttempts = 8,
  FutureOr<bool> Function(Object error, int attempt)? retryIf,
}) =>
    BackOff(
      func,
      delayFactor: delayFactor,
      randomizationFactor: randomizationFactor,
      maxDelay: maxDelay,
      maxAttempts: maxAttempts,
      retryIf: retryIf,
    ).call();