Coder Social home page Coder Social logo

ptzagk / redux-fries Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nicolasdelfino/redux-fries

0.0 0.0 0.0 13 KB

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

License: MIT License

JavaScript 100.00%

redux-fries's Introduction

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)

redux-fries's People

Contributors

nicolasdelfino avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.