redux-call-effect
A declarative way to call action creators.
npm install --save redux-call-effect
; // Before:;// After:;
Why?
To simplify testing.
In some cases calling action creators imperatively makes testing virtually impossibe, especially when using thunks. Consider this example:
// Source:const onResultSaved = { /* ... */}; const saveResult = { /* ... */ ;}; // Test:;
We cannot easily check if a correct thunk was dispatched. redux-call-effect
to the rescue:
// Source:const onResultSaved = { /* ... */}; const saveResult = { /* ... */ ;}; // Test:;
Installation
npm install --save redux-call-effect
Before you can use call
you have to inject the middleware with applyMiddleware
:
;;; const store = ;
Inspiration
This project is of course inspired by the call
effect from the awesome redux-saga.
License
MIT