Skip to content

Commit ee689f9

Browse files
committed
Updated Modules documentation.
1 parent a102f7b commit ee689f9

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

docs/Introduction.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
# Introduction
22

33
## Motivation
4-
A way of creating a modularized and universal system which has its state under control, using Redux as its core.
4+
5+
A way of creating a modularized and universal system which has its state under control, using Redux as its core.
56

6-
Reduce boilerplate when using a "[Redux](https://github.com/reactjs/redux/) stack".
7+
Reduce boilerplate when using a "[Redux](https://github.com/reactjs/redux/) stack".
78

89
## Principles
9-
Based on the Functional Programming principles / paradigms.
10+
11+
Based on the Functional Programming principles / paradigms.
1012

1113
1. Changes of the state are explicit.
1214
2. Eliminate redundant code.
13-
3. State less functions (no *this* keyword).
15+
3. Stateless functions (no *this* keyword).
1416
4. Side-effects, are reactions from dispatched actions.
1517
5. The value of variables are immutable. Create a new value instead of changing.
16-
6. Modules and functions should have one goal.
17-
7. Keep your logic state less.
18+
6. Modules and functions should have just one goal.
19+
7. Keep your logic stateless.
1820

docs/Modules.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Modules
22

3-
A module is made of a [**reducer**](Reducers.md) and/or a [**middleware**](Middlewares.md) which assumes the actions are [FSA](https://github.com/acdlite/flux-standard-action) compliant, and also can be implemented a [**store enhancer**](http://redux.js.org/docs/Glossary.html#store-enhancer).
3+
A module implements a [reducer](Reducers.md) and/or a [middleware](Middlewares.md). They should deal with a standard [Redux store](http://redux.js.org/docs/api/Store.html) and assume all actions are [FSA](https://github.com/acdlite/flux-standard-action) compliant. Modules can also implement a [store enhancer](http://redux.js.org/docs/Glossary.html#store-enhancer).
44

5-
Its **signature** is the following:
5+
The basic module structure is the following:
66

77
```js
88
const module = {
@@ -21,8 +21,9 @@ const module = {
2121

2222
}
2323
```
24-
---
25-
Using[ **redux-actions**](https://github.com/acdlite/redux-actions) and **middleware handlers** signature:
24+
25+
For convenience and better code readability, the reducer can also be an object. If so, it's meant to be a [redux-actions](https://github.com/acdlite/redux-actions) action handler object. Redux Boot also provides middleware handlers which are like redux-actions action handlers but for middlewares:
26+
2627
```js
2728
import boot, {BOOT} from 'redux-boot'
2829

@@ -52,16 +53,21 @@ const module = {
5253
}
5354

5455
}
55-
5656
```
57-
---
57+
58+
This is useful to avoid deeply nested `switch` and `if` statements that can have a bad impact in code readability and simplicity. By using objects, reducers and middlewares can respond to specific action types.
59+
60+
5861
Using[ **redux-actions**](https://github.com/acdlite/redux-actions) and[ **redux-promise**](https://github.com/acdlite/redux-promise) signature:
62+
63+
[//]: # (Move this to advanced?)
64+
5965
```js
60-
import {BOOT} from 'redux-boot';
61-
import {createAction} from 'redux-actions';
62-
import parseRoutesFiles from './parseRoutesFiles';
66+
import {BOOT} from 'redux-boot'
67+
import {createAction} from 'redux-actions'
68+
import parseRoutesFiles from './parseRoutesFiles'
6369

64-
const LOAD_ROUTES = 'redux-boot/routes/LOAD';
70+
const LOAD_ROUTES = 'redux-boot/routes/LOAD'
6571
const loadRoutesAction = createAction(LOAD_ROUTES, async () => {
6672

6773
// parseRoutesFiles returns a promise, so its an async function.
@@ -118,18 +124,17 @@ const module = {
118124

119125
}
120126
```
121-
---
122-
## Standard signature of a module file
123127

124-
`@file: /modules/user/index.js`
125-
```js
126-
// Notice we don't use the ";".
128+
## Module file basic structure
129+
130+
[//]: # (Add link to code style?)
127131

132+
```js
128133
import {BOOT} from 'redux-boot'
129134
import {createAction} from 'redux-actions'
130135

131136
// Use an action constant type from other module.
132-
// Notice the path is relative, we assume you use Webpack.
137+
// Notice the path is relative, we assume we are using Webpack.
133138
import {SUBMIT_FORM} from 'modules/forms'
134139

135140
// Exporting "export" an action means its public to use it outside

0 commit comments

Comments
 (0)