Skip to content

Instantly share code, notes, and snippets.

@HoverBaum
Created July 20, 2016 02:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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