Created
August 7, 2015 16:24
-
-
Save aaronjensen/88b8f69fb74d0c4fb1d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function simpleDispatchThunkMiddleware({ dispatch, getState }) { | |
const newDispatch = (type, payload) => { | |
if (typeof type === 'object') { | |
dispatch(type); | |
} else { | |
dispatch({ type, payload }); | |
} | |
}; | |
return next => action => | |
typeof action === 'function' ? | |
action(newDispatch, getState) : | |
next(action); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment