Skip to content

Instantly share code, notes, and snippets.

@fizerkhan
Last active Jan 5, 2017
Embed
What would you like to do?
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