Use with Reducers
const FOO_TYPE = 'FOO';
// Dispatch the action
const fooActionCreator = () => ({
type: FOO_TYPE
payload: Promise.resolve('foo')
});
// Handle the action
const fooReducer = (state = {}, action) => {
switch(action.type) {
case `${FOO_TYPE}_PENDING`:
return;
case `${FOO_TYPE}_FULFILLED`:
return {
isFulfilled: true,
data: action.payload
};
case `${FOO_TYPE}_REJECTED`:
return {
isRejected: true,
error: action.payload
};
default: return state;
}
}Action Types
Large Applications
Last updated