Redux-Observable extension for @duckness/duck - Modular Redux Ducks hatchery
npm install @duckness/epic@duckness/epic Redux-Observable extension for @duckness/duck






``js
// counterDuck.js
import EpicDuck from '@duckness/epic'
import { map, delay } from 'rxjs/operators'
import { ofType } from 'redux-observable'
// Create duck with the name 'counter' for 'counter-app' app
const counterDuck = EpicDuck('counter', 'counter-app')
// Add actions
counterDuck.action('increment', 'INCREMENT')
counterDuck.action('incrementAsync', 'INCREMENT_ASYNC')
// add epic
counterDuck.epic(function incrementAsync(action$, state$, duckFace) {
return action$.pipe(
ofType(duckFace.actionTypes.INCREMENT_ASYNC),
delay(1000),
map(action => duckFace.action.increment(action.payload))
)
})
// root epic
export const rootEpic = counterDuck.rootEpic
`
- Example
- API
- Epic
- .epic(epic)
- .rootEpic
- Error reporter
- .setErrorReporter
- .reportError(error)
- @Duckness packages:
EpicDuck extends duckness Duck
Adds a new epic to the duck
`js`
myDuck.epic(function myEpic(action$, state$, duckFace) { /.../ })
Duck's root epic with epics isolation (exceptions in one epic will not break other epics).
`js`
myDuck.rootEpic
Set error reporter (default is console.error) that reports uncatched epic errors`js`
myDuck.setErrorReporter(error => {
window.Sentry.captureException(error)
})
Call assigned error reporter
`js``
myDuck.reportError(new Error('Clean duck!'))
* @duckness/duck - Modular Redux Ducks hatchery
* @duckness/saga - Redux Saga extension for @duckness/duck
* @duckness/epic - Redux-Observable extension for @duckness/duck
* @duckness/pool - @duckness/duck + Redux
* @duckness/pool-saga-stream - @duckness/saga plugin for @duckness/pool
* @duckness/pool-epic-stream - @duckness/epic plugin for @duckness/pool
* @duckness/react-redux-pool - @duckness/pool + React-Redux
* @duckness/use-redux - React hook for Redux store
* @duckness/use-pool - React hook for @duckness/pool.
* @duckness/store - simple store for React components
* @duckness/reactor - reactive data flow builder