Skip to content

Instantly share code, notes, and snippets.

@aaronjensen
Created August 7, 2015 16:40
Show Gist options
  • Save aaronjensen/fc2e34c32e6c165ae647 to your computer and use it in GitHub Desktop.
Save aaronjensen/fc2e34c32e6c165ae647 to your computer and use it in GitHub Desktop.
function addSimpleDispatch(thunk) {
return ({ dispatch, getState }) => {
function simpleDispatch(type, payload) {
if (typeof type === 'string') {
return dispatch({ type, payload });
} else {
return dispatch(type);
}
}
return thunk({ dispatch: simpleDispatch, getState });
};
}
const finalCreateStore = compose(
applyMiddleware(addSimpleDispatch(thunkMiddleware)),
batchedUpdates,
createStore
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment