Created
July 20, 2016 02:40
-
-
Save HoverBaum/022905d9c6ca4f7fcd06664ea7e63415 to your computer and use it in GitHub Desktop.
Logging middleware for Redux.
This file contains 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
/* | |
Logging middleware for Redux as suggested by the official documentation. | |
http://redux.js.org/docs/advanced/Middleware.html | |
*/ | |
export const logger = store => next => action => { | |
console.log('dispatching\n', action) | |
let result = next(action) | |
console.log('next state\n', store.getState()) | |
return result | |
} | |
export const crashReporter = store => next => action => { | |
try { | |
return next(action) | |
} catch (err) { | |
console.error('Caught an exception!', err) | |
Raven.captureException(err, { | |
extra: { | |
action, | |
state: store.getState() | |
} | |
}) | |
throw err | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment