redux-saga-try-catch
v4.0.7
Published
A saga utility to reduce flow control boilerplate
Downloads
1,371
Readme
redux-saga-try-catch
includes TypeScript definitions
A saga utility to reduce flow control boilerplate. See the tests.
Install
$ npm install redux-saga-try-catch
Use
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