Skip to content

Instantly share code, notes, and snippets.

@HoverBaum
Created July 20, 2016 02:40
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 HoverBaum/022905d9c6ca4f7fcd06664ea7e63415 to your computer and use it in GitHub Desktop.
Save HoverBaum/022905d9c6ca4f7fcd06664ea7e63415 to your computer and use it in GitHub Desktop.
Logging middleware for Redux.
/*
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