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.

Commitf26ed3b

Browse files
author
Vince Speelman
committed
chore(docs): add usage documentation and example
1 parenta37c61c commitf26ed3b

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
dist
33
yarn-error.log
4+
coverage

‎README.md‎

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,62 @@
77
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?longCache=true&style=flat-square)](http://commitizen.github.io/cz-cli/)
88
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?longCache=true&style=flat-square)](https://conventionalcommits.org)
99
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?longCache=true&style=flat-square)](https://github.com/prettier/prettier)
10-
[![license](https://img.shields.io/github/license/VinSpee/async-redux-action-creators.svg?longCache=false&style=flat-square)](https://github.com/VinSpee/async-redux-actions/blob/master/LICENSE)
10+
[![license](https://img.shields.io/github/license/VinSpee/async-redux-action-creators.svg?longCache=true&style=flat-square)](https://github.com/VinSpee/async-redux-actions/blob/master/LICENSE)
11+
12+
```
13+
({
14+
prefix: String,
15+
states: [...String]
16+
}) => ({ entity: String }) => {
17+
...[String]: ReduxAction
18+
}
19+
```
20+
21+
##install
22+
23+
`yarn add -D async-redux-actions redux-actions`
24+
25+
##What
26+
27+
async-redux-actions is a small helper that uses[redux-actions](https://redux-actions.js.org/) 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.
28+
29+
##Why
30+
31+
I like using`redux-actions` in conjunction with[redux-promise-middleware](https://github.com/pburtchaell/redux-promise-middleware), but felt icky about writing things like`${userActions.signIn.toString()}/RECEIVED`.
32+
33+
##How
34+
35+
```js
36+
// user.js
37+
38+
importcreateActionsfrom'async-redux-actions';
39+
40+
constactions=createActions({
41+
states: ['REQUESTED','RECEIVED','REJECTED'],
42+
prefix:'💎',
43+
});// returns an function that is waiting on an entity and an object of actions.
44+
45+
exportdefaultactions({ entity:'user' })({
46+
PROFILE:promiseApi.getProfile,
47+
});
48+
```
49+
50+
That will create these action creators and types:
51+
52+
###action creators
53+
54+
-`profile.requested()`
55+
-`profile.received()`
56+
-`profile.rejected()`
57+
-`profile()`
58+
59+
along side of`redux-promise-middleware`, dispatching`profile` will kick off
60+
each action according to it's state, just like normal.
61+
62+
###types
63+
64+
-`'💎/USER/PROFILE/REQUESTED'`,
65+
-`'💎/USER/PROFILE/RECEIVED'`,
66+
-`'💎/USER/PROFILE/REJECTED'`
67+
68+
here's a[full sample](https://codesandbox.io/s/r0r7wpjz1o)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp