@vgerbot/async
    Preparing search index...

    Function retry

    • Wraps an async task with retry logic. The task will be retried according to the specified retry options if it fails.

      Type Parameters

      • T

        The type of the task result

      Parameters

      • task: AsyncTask<T>

        The async task to execute

      • retryOptions: RetryOptions

        Retry configuration (maxAttempts, delay, backOff, retryIf)

      • Optionaloptions: CancellableOptions<T>

        Additional cancellable configuration options

      Returns CancellableHandle<T>

      A cancellable handle that resolves to the task result

      const handle = retry(
      async (token) => {
      const response = await fetch('/api/data');
      return response.json();
      },
      {
      maxAttempts: 3,
      delay: 1000,
      backOff: 'exponential',
      },
      );

      const data = await handle;