This effect is used when describing the SUCCESS
case of the SUCCESS-FAILURE
pattern.
This effect is a multi-target effect - It modifies more than one target at the same time.
It will:
- Put
${action.target}Loading
infalse
- Put
${action.target}Error
innull
- Fill
${action.target}
with youraction.payload
by default, or use a selector provided - Put
${action.target}IsRetrying
infalse
ifaction.isPolling
is truthy - Put
${action.target}CountRetry
in0
ifaction.isPolling
is truthy
Example:
const selector =
(action, state) => action.payload || state[action.target];
const reducerDescription = {
'SUCCESS': onSuccess(),
'SUCCESS_CUSTOM': onSuccess(selector)
};
onSuccess
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