This library simplify the use of redux-thunk minimizing the boilerplate coding.
npm install --save redux-thunk-addon
You can use this addon into a project with redux and redux-thunk configured inside.
In this project you can do the following steps:
- Create your redux actions using
asyncCallAction
function:
asyncCallAction(
<action string>,
<promise function used for api call>,
<arguments passing to api call>,
);
Inside the actions file export an object with the actions string.
- Insert new addon reducers into reducers collection:
api: apiReducer(<array of actions string object>),
- Where you have to calll the api, you can use redux to dispatch the actions created before and you can find the status in the corrisponding reducers (
state.api[<action name>]
).
In the Example
folder you can find a small redux example with this library.