- Notifications
You must be signed in to change notification settings - Fork0
Generate async redux action types and creators
License
VinSpee/async-redux-actions
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
({ prefix: String, states: [...String]}) => ({ entity: String }) => { ...[String]: ReduxAction}yarn add -D async-redux-actions redux-actions
async-redux-actions is a small helper that usesredux-actions to create a set of action creators and action types that you can use for all of your app's actions. It helps you by taking an object of actions and returning a set of action creators and actions types.
I like usingredux-actions in conjunction withredux-promise-middleware, but felt icky about writing things like${userActions.signIn.toString()}/RECEIVED.
// user.jsimportcreateActionsfrom'async-redux-actions';constactions=createActions({states:['REQUESTED','RECEIVED','REJECTED'],prefix:'💎',});// returns an function that is waiting on an entity and an object of actions.exportdefaultactions({entity:'user '})({PROFILE:promiseApi.getProfile,});
That will create these action creators and types:
profile.requested()profile.received()profile.rejected()profile()
along side ofredux-promise-middleware, dispatchingprofile will kick offeach action according to it's state, just like normal.
'💎/USER/PROFILE/REQUESTED','💎/USER/PROFILE/RECEIVED','💎/USER/PROFILE/REJECTED'
here's afull sample
About
Generate async redux action types and creators
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.