Skip to content

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

License

Notifications You must be signed in to change notification settings

ptzagk/redux-fries

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%