redux-offline-chain
Version:
chain as many offline actions as you like
13 lines (12 loc) • 349 B
JavaScript
export default ({ dispatch, getState }) => next => action => {
const result = next(action)
if (action.meta && typeof action.meta.then === 'function') {
const invoked = action.meta.then(action.payload)
if (typeof invoked === 'function') {
invoked(dispatch, getState)
} else {
dispatch(invoked)
}
}
return result
}