Skip to content

Instantly share code, notes, and snippets.

@aaronjensen
Created August 7, 2015 16:24
Show Gist options
  • Save aaronjensen/88b8f69fb74d0c4fb1d4 to your computer and use it in GitHub Desktop.
Save aaronjensen/88b8f69fb74d0c4fb1d4 to your computer and use it in GitHub Desktop.
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