Skip to content

Commit 4fdfdf9

Browse files
committed
Added tldr section
1 parent b8c2d53 commit 4fdfdf9

File tree

1 file changed

+52
-15
lines changed

1 file changed

+52
-15
lines changed

README.md

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,37 @@
22
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors)
33
[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors)
44
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors)
5+
56
Reduce boilerplate of your Redux actions by creating [flux-standard-actions](https://github.com/acdlite/flux-standard-action) with a set of utilities this package provides.
67

78
## TL;DR
89

9-
### Table of contents
10-
* [Install](#install)
11-
* [Usage](#usage)
12-
* [API](#api)
13-
* [createAction](#createaction)
14-
* [`createAction(type)`](#createactiontype)
15-
* [`createAction(type, payloadCreator)`](#createactiontype-payloadcreator)
16-
* [`createAction(type, payloadCreator, metaCreator)`](#createactiontype-payloadcreator-metacreator)
17-
* [createRequestTypes](#createRequestTypes)
18-
* []
10+
```javascript
11+
// actions.js
12+
import {
13+
createAction,
14+
createRequestTypes,
15+
createRequestActions
16+
} from 're-create-actions';
17+
18+
// Constans
19+
const GET_GITHUB_USERS = 'GET_GITHUB_USERS';
20+
21+
// Create action creator
22+
export const getGithubUsers = createAction(GET_GITHUB_USERS);
23+
// Use: dispatch(getGithubUsers())
24+
25+
// Create network types/constants
26+
const GET_GITHUB_USERS_RT = createRequestTypes('GET_GITHUB_USERS_RT');
27+
// Use: GET_GITHUB_USERS_RT.REQUESTED, GET_GITHUB_USERS_RT.COMPLETED, GET_GITHUB_USERS_RT.FAILED
1928

20-
## Install
29+
// Create actions from network types
30+
const getGithubUsersRT = createRequestActions(GET_GITHUB_USERS_RT);
31+
// Use: dispatch(getGithubUsersRT.requested())
32+
33+
```
34+
35+
# Install
2136

2237
### NPM
2338
```bash
@@ -29,19 +44,41 @@ $ npm install re-create-actions --save
2944
$ yarn add re-create-actions
3045
```
3146

32-
## Usage
47+
# Usage
3348
Every helper will create action that is defined in shape by Flux standard action. We decided to go with Flux standard action because it gives you definition of minimal, common standards that are human-friendly and enable
3449
us to create assumptions about the shape of our actions.
3550

3651
*NOTE*: You can't disable flux standard action structure at the moment. But there is an [open issue]() for this.
3752

38-
## API
53+
# API
54+
55+
## createAction (type, payloadCreator, metaCreator)
56+
57+
#### type (required)
58+
Type: `string`
59+
60+
Type for your type property in [action](https://redux.js.org/basics/actions)
61+
62+
#### payloadCreator (optional)
63+
Type: `function`
64+
65+
Custom payload creator for action payload
66+
67+
#### metaCreator (optional)
68+
Type: `function`
69+
70+
Custom meta creator for action
71+
72+
73+
# createRequestTypes(type)
3974

40-
### createAction
75+
#### type
76+
Type: `string`
4177

78+
Type for your request types
4279

4380
## Credits
44-
Projects was inspired by headaches given from reading bunch of boilerplates` during pull request reveiws at [reactor.studio](https://github.com/reactor-studio`).
81+
Projects was inspired by headaches given from reading bunch of boilerplates during pull request reveiws at [reactor.studio](https://github.com/reactor-studio`).
4582

4683
API for this package was inspired by this awesome projects:
4784
* [flux-standard-action](https://github.com/acdlite/flux-standard-action)

0 commit comments

Comments
 (0)