create-async-action
wrapper for redux-actions createAction function for better work with redux-promise-middleware
When using redux-actions and redux-promise-middleware together its annoying to do something like this:
const myAction = createAction('MY_ACTION', async () => {
...
});
const reducer = handleActions({
[myAction + '_SUCCESS']: () => ...
[myAction + '_ERROR']: () => ...
[myAction + '_LOADING']: () => ...
}, { ... })
Instead of this you can do something like this:
import createAsyncAction from 'create-async-action';
const myAction = createAsyncAction('MY_ACTION', async () => {
});
const reducer = handleActions({
[myAction.success]: () => ...
[myAction.error]: () => ...
[myAction.loading]: () => ...
}, { ... })
Yes, here I use custom suffixes for redux-promise-middleware.
Thanks for inspiring, matpaul