Last active
June 15, 2017 23:34
-
-
Save bradennapier/39d6f86c6c57cc8a7405320c001854f2 to your computer and use it in GitHub Desktop.
Error Event and Promise Rejection Monitor via Saga and saga-event-observer
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
import { call } from 'redux-saga/effects' | |
import eventObserverSaga from 'saga-event-observer' | |
/* | |
handlers looks something like this: | |
this.eventHandlers = { | |
onEvent: [ this, this.handleEvent ], | |
onError: [ this, this.handleError ], | |
onCancel: [ this, this.handleCancel ], | |
} | |
*/ | |
export default function* startKeypressMonitor(config, handlers) { | |
if ( ! config.monitor.errors ) { return } | |
yield call( | |
eventObserverSaga, | |
'errors-observer', | |
[ 'error' ], | |
handlers | |
) | |
yield call( | |
eventObserverSaga, | |
'promise-rejection-observer', | |
[ 'unhandledrejection' ], | |
handlers | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment