Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 23, 2020. It is now read-only.

Generate async redux action types and creators

License

NotificationsYou must be signed in to change notification settings

VinSpee/async-redux-actions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TravisCoverage Statusnpm bundle size (minified + gzip)Tested with Jestsemantic-releaseCommitizen friendlyConventional Commitsstyled with prettierlicense

({  prefix: String,  states: [...String]}) => ({ entity: String }) => {  ...[String]: ReduxAction}

install

yarn add -D async-redux-actions redux-actions

What

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.

Why

I like usingredux-actions in conjunction withredux-promise-middleware, but felt icky about writing things like${userActions.signIn.toString()}/RECEIVED.

How

// 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:

action creators

  • 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.

types

  • '💎/USER/PROFILE/REQUESTED',
  • '💎/USER/PROFILE/RECEIVED',
  • '💎/USER/PROFILE/REJECTED'

here's afull sample

About

Generate async redux action types and creators

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp