This package allows you to subscribe to changes in any part of Redux state.
npm install redux-subscriber --save
;;const store = ;// "initSubscriber" returns "subscribe" function, so you can use itconst subscribe = ;
// or you can just import "subscribe" function from the package;const unsubscribe =;// if you want to stop listening to changes;
- https://github.com/ivantsov/yandex-mail-notifier-chrome - real app that uses
initSubscriber(store) (default export) - initialize
redux-subscriber, so after that you can use
store- instance of Redux store.
subscribe(key, callbackFunction) - subscribe
callbackFunction to changes.
key- string which specified the part of state (e.g.
user.message.count) to listen to.
callbackFunction- function which will be called when the part of state has changed. New state is passed as a parameter.
unsubscribe function which can be called to unsubscribe from changes.