redux-reactions
Action handler middleware for Redux.
npm install --save redux-reactions
Motivation
I felt I needed a way to wait for an action to be dispatched in Redux, and respond to it in some way other than manipulating the store.
Like redux-saga, but much lighter.
Inspiration
Lots of people have had a take on this, here are some middlewares I found that may suit you better:
- redux-listeners
- redux-observable
- redux-hook-middleware
- redux-listener
- redux-fries
- redux-action-listeners
Usage
First, register the middleware:
store.js
;;const todoApp = ;const store = ;
Next up, just like your actions go into a seperate file; for example actions/index.js
, your reactions should also be seperated:
reactions/index.js
; { ;}
And now in your container, register your reactions:
containers/todo.js
;; ;;const mapStateToProps = {};const mapDispatchToProps = {}; ; mapStateToProps mapDispatchToPropsTodoList;
Thanks
Many thanks to Ben Anderson for giving up the redux-reactions npm package name.