Naughty Platypus Memorabilia

    @duckness/epic

    0.9.0 • Public • Published

    @duckness/epic

    Redux-Observable extension for @duckness/duck

    NPM License Libraries.io dependency status for latest release, scoped npm package GitHub issues vulnerabilities npm bundle size

    Example

    // 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

    Table of Contents

    API

    EpicDuck extends duckness Duck

    Epic

    .epic(epic)

    Adds a new epic to the duck

    myDuck.epic(function myEpic(action$, state$, duckFace) { /*...*/ })

    .rootEpic

    Duck's root epic with epics isolation (exceptions in one epic will not break other epics).

    myDuck.rootEpic

    Error reporter

    .setErrorReporter

    Set error reporter (default is console.error) that reports uncatched epic errors

    myDuck.setErrorReporter(error => {
      window.Sentry.captureException(error)
    })

    .reportError(error)

    Call assigned error reporter

    myDuck.reportError(new Error('Clean duck!'))

    @Duckness packages:

    Install

    npm i @duckness/epic

    DownloadsWeekly Downloads

    22

    Version

    0.9.0

    License

    MIT

    Unpacked Size

    12 kB

    Total Files

    5

    Last publish

    Collaborators

    • hitosu