Redux loading promise middleware
Middleware for Redux that turns promises into several dispatches of loading, success and error states.
It is useful for getting asynchronous data (eg. API calls) into your redux store. Works well together with redux-actions and is inspired by redux-promise.
It is similar to FSA pattern but has some differences:
- it dispatch async actions twice: when Promise is started and when promise is finished
- it has
isLoading
param that can be checked if promise is finished - when Promise is rejected,
error
param
Installation
This package is distributed via npm.
npm install redux-loading-promise-middleware
Example usage
// store.js;;;; const middlewares = ; return ;
// reducer.jsconst initialState = todos: isLoading: false error: null; { }
// action.jsconst fetchTodos = ;