Skip to content

Instantly share code, notes, and snippets.

@Shuumatsu
Last active March 27, 2017 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shuumatsu/f8028235d5e6f73cd2bcb93b8987556d to your computer and use it in GitHub Desktop.
Save Shuumatsu/f8028235d5e6f73cd2bcb93b8987556d to your computer and use it in GitHub Desktop.
function createThunkMiddleware(extraArgument) {
return ({ dispatch, getState }) => next => action => {
if (typeof action === 'function') {
return action(dispatch, getState, extraArgument);
}
return next(action);
};
}
const thunk = createThunkMiddleware();
thunk.withExtraArgument = createThunkMiddleware;
export default thunk;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment