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.
Example
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';
Creates an Effect description that instructs the middleware to call the function
fn
withargs
as arguments. In case of failure will try to make another call afterdelay
milliseconds, if a number of attempts <maxTries
.Example
In the following example, we create a basic task
retrySaga
. We useretry
to try to fetch our API 3 times with 10 second interval. Ifrequest
fails first time thanretry
will callrequest
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 } }) } }