redux-saga-try-catch
TypeScript icon, indicating that this package has built-in type declarations

4.0.6 • Public • Published

Build Status Standard - JavaScript Style Guide npm version

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

FSA

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

FSA with meta

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

Readme

Keywords

Package Sidebar

Install

npm i redux-saga-try-catch

Weekly Downloads

352

Version

4.0.6

License

MIT

Unpacked Size

68.4 kB

Total Files

28

Last publish

Collaborators

  • killtheliterate