includes TypeScript definitions
A saga utility to reduce flow control boilerplate. See the tests.
$ npm install redux-saga-try-catch
import Catch from 'redux-saga-try-catch'
const io = {
log: console.log
}
function* aSaga() {
throw new Error('oh no!')
}
const aSafeSaga = Catch.standardAction(aSaga, io)
aSafeSaga({ type: 'AN_ACTION' }) // logs the error
import Catch from 'redux-saga-try-catch'
const io = {
log: console.log
}
function* aSaga() {
throw new Error('oh no!')
}
const aSafeSaga = Catch.deferredAction(aSaga, io)
const action = {
type: 'AN_ACTION',
meta: {
deferred: {
success: console.log, // a success callback - could be `resolve`
failure: console.err // a failure callback - could be `reject`
}
}
}
aSafeSaga() // logs the error