Created
November 7, 2016 14:23
-
-
Save lmatteis/d74bf3af342cda96fcac24f862981070 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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