You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Modules.md
+21-16Lines changed: 21 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
# Modules
2
2
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).
4
4
5
-
Its **signature** is the following:
5
+
The basic module structure is the following:
6
6
7
7
```js
8
8
constmodule= {
@@ -21,8 +21,9 @@ const module = {
21
21
22
22
}
23
23
```
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
+
26
27
```js
27
28
importboot, {BOOT} from'redux-boot'
28
29
@@ -52,16 +53,21 @@ const module = {
52
53
}
53
54
54
55
}
55
-
56
56
```
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.
0 commit comments