@laserware/stasis
    Preparing search index...

    Function retry

    • Creates an Effect description that instructs the middleware to call the function fn with args as arguments. In case of failure will try to make another call after delay milliseconds, if a number of attempts < maxTries.

      In the following example, we create a basic task retrySaga. We use retry to try to fetch our API 3 times with 10 second interval. If request fails first time than retry will call request one more time while calls count less than 3.

      import { put, retry } from 'redux-saga/effects' import { request } from 'some-api';

      function* retrySaga(data) { try { const SECOND = 1000 const response = yield retry(3, 10 * SECOND, request, data) yield put({ type: 'REQUEST_SUCCESS', payload: response }) } catch(error) { yield put({ type: 'REQUEST_FAIL', payload: { error } }) } }

      Type Parameters

      • Fn extends (...args: any[]) => any

      Parameters

      • maxTries: number

        maximum calls count.

      • delayLength: number
      • fn: Fn

        A Generator function, or normal function which either returns a Promise as a result, or any other value.

      • ...args: Parameters<Fn>

        An array of values to be passed as arguments to fn

      Returns CallEffect<SagaReturnType<Fn>>