Skip to content
This repository has been archived by the owner. It is now read-only.
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Async Redux Action Creators

Travis Coverage Status npm bundle size (minified + gzip) Tested with Jest semantic-release Commitizen friendly Conventional Commits styled with prettier license

({
  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 uses redux-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 using redux-actions in conjunction with redux-promise-middleware, but felt icky about writing things like ${userActions.signIn.toString()}/RECEIVED.

How

// user.js

import createActions from 'async-redux-actions';

const actions = createActions({
  states: ['REQUESTED', 'RECEIVED', 'REJECTED'],
  prefix: '💎',
}); // returns an function that is waiting on an entity and an object of actions.

export default actions({ entity: 'user ' })({
  PROFILE: promiseApi.getProfile,
});

That will create these action creators and types:

action creators

  • profile.requested()
  • profile.received()
  • profile.rejected()
  • profile()

along side of redux-promise-middleware, dispatching profile will kick off each action according to it's state, just like normal.

types

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

here's a full sample

About

Generate async redux action types and creators

Topics

Resources

License

Packages

No packages published