create-async-action
v1.0.1
Published
wrapper for redux-actions createAction function for better work with redux-promise-middleware
Downloads
6
Maintainers
Readme
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 () => {
// the same code as before
});
const reducer = handleActions({
[myAction.success]: () => ...
[myAction.error]: () => ...
[myAction.loading]: () => ...
}, { ... })
Yes, here I use custom suffixes for redux-promise-middleware.
Thanks for inspiring, matpaul