Last active
January 5, 2017 17:25
-
-
Save fizerkhan/356457a28caaad5a2bde9fa6e1d23aaf to your computer and use it in GitHub Desktop.
AtatusJS Redux Middleware
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
// Add atatus middlware to your redux store | |
import atatusMiddleware from './redux-atatus-middleware'; | |
createStore( | |
rootReducer, | |
initialState, | |
applyMiddleware(atatusMiddleware()) | |
); |
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
// 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