Skip to content

Instantly share code, notes, and snippets.

@bradennapier
Last active June 15, 2017 23:34
Show Gist options
  • Save bradennapier/39d6f86c6c57cc8a7405320c001854f2 to your computer and use it in GitHub Desktop.
Save bradennapier/39d6f86c6c57cc8a7405320c001854f2 to your computer and use it in GitHub Desktop.
Error Event and Promise Rejection Monitor via Saga and saga-event-observer
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