Skip to content

Instantly share code, notes, and snippets.

@lmatteis
Created November 7, 2016 14:23
Show Gist options
  • Save lmatteis/d74bf3af342cda96fcac24f862981070 to your computer and use it in GitHub Desktop.
Save lmatteis/d74bf3af342cda96fcac24f862981070 to your computer and use it in GitHub Desktop.
// Must be defined before thunk
const promiseCatcher = store => next => action => {
if (typeof action !== 'function') {
return next(action);
}
const decoratedAction = (dispatch, getState) => {
const p = action(dispatch, getState);
return Promise.resolve(p).then(err => console.log(action));
};
return next(decoratedAction);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment