Skip to content

Instantly share code, notes, and snippets.

@fizerkhan
Last active January 5, 2017 17:25
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 fizerkhan/356457a28caaad5a2bde9fa6e1d23aaf to your computer and use it in GitHub Desktop.
Save fizerkhan/356457a28caaad5a2bde9fa6e1d23aaf to your computer and use it in GitHub Desktop.
AtatusJS Redux Middleware
// Add atatus middlware to your redux store
import atatusMiddleware from './redux-atatus-middleware';
createStore(
rootReducer,
initialState,
applyMiddleware(atatusMiddleware())
);
// redux-atatus-middleware.js
declare var atatus: any;
export default function createMiddleware () {
return store => next => action => {
try {
return next(action); // dispatch
} catch (err) {
atatus.notify(err, { // send to crash reporting tool
extra: {
action,
}
});
throw err; // re-throw error
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment