This effect is used when the shouldRetry
function of a polling action returns a truthy value. It sets up the state with the info related to the next try.
This effect is a multi-target effect - It modifies more than one target at the same time.
It will:
- Set
${action.target}IsRetrying
astrue
- Set
${action.target}Loading
asfalse
- Increment
${action.target}RetryCount
by 1 - Set
${action.target}Error
asaction.payload.error
by default. - Set
${action.target}
asaction.payload.interval
Example:
const selector =
(action, state) => action.payload.customError || state.defaultError;
const reducerDescription = {
'RETRY': onRetry(),
'RETRY_CUSTOM': onRetry(selector)
};
onRetry
effect receives an optional parameter:
- selector: This function describes how we read the data from the
action
.
(action, state) => any
By default, is:
action => action.payload.error