redux-future
FSA-compliant future monad middleware for Redux.
This is based on redux-promise.
npm install --save redux-future
Usage
;
The default export is a middleware function. If it receives a future, it will dispatch the resolved value of the future (after forking the future). It will dispatch the error if one occures.
If it receives an Flux Standard Action whose payload
is a future, it will fork
and then either
- dispatch a copy of the action with the resolved value of the future.
- dispatch a copy of the action with the rejected value of the future, and set
error
totrue
.
Example
const result = ; const resultFiltered = result; // will hold [1, 2] store;
Using in combination with redux-actions
Because it supports FSA actions, you can use redux-future in combination with redux-actions.
Example: Action creators
const result = ; const resultFiltered = result; // will hold [1, 2] ;// orconst filterAction = ;;
Example: Future(IO)
You can use redux-future
together with redux-io
.
// futureIo :: Future(IO(String))const futureIo = { const io = ; ;}; const action = ;store;
Related
Resources
Don't know what a future is? Read the following blog post or watch the video.
Libraries
- folktale data.task
- ramda-fantasy
- fantasy-future
- futurize - Turn callback-style functions or promises into futures
- redux-io - FSA-compliant IO monad middleware for redux
- redux-either - FSA-compliant Either monad middleware for redux