Nine Parsecs from Milwaukee

    redux-fries

    1.0.1 • Public • Published

    redux-fries 🍟

    Build Status

    "Greasy middleware for subscribing to actions and creating tasty side-effects in your code"

    codesandbox demo

    https://codesandbox.io/s/pY5My9A5y

    INSTALL

    yarn add redux-fries

    REASON

    Found the need when working on a legacy project that mixed the imperative / declarative paradigmns. Considered somewhat of an anti-pattern on a pure React project so use with care.

    SUBSCRIBE

    import { subscribe, unsubscribe } from 'redux-fries'

    Pass the action key to subscribe and the callback that you want fired when that action dispatches.

    const localSub = subscribe('SOME_ACTION', callback)
    const callback = state => console.log(state) // e.g { subscribed:true }

    UNSUBSCRIBE

    The const localSub now holds the unique id returned from subscribe, this ID consists of the key argument plus a unique identifier, e.g 'SOME_ACTION_#1' To unsubscribe you just call the unsubscribe method with the unique id as the argument:

    unsubscribe(localSub)

    Install

    npm i redux-fries

    DownloadsWeekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • nicolasdelfino