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: README.md
+23-2Lines changed: 23 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,10 +84,16 @@ const setX = x => reduceFoo(state => ({ ...state, x }));
84
84
85
85
## Middlewares
86
86
87
-
A repatch middleware takes the store instanceand the previous reducer and returns a new reducer:
87
+
A repatch middleware takes the `store` instance, a `next` function and the previous `reducer`. The middleware can provide a new reducer via the `next` function.
88
88
89
89
```javascript
90
-
(Store, Reducer): Reducer
90
+
Middleware: Store -> (Reducer -> Reducer) -> Reducer -> any
91
+
```
92
+
93
+
where
94
+
95
+
```javascript
96
+
Next: Reducer -> Reducer
91
97
```
92
98
93
99
Use the `addMiddleware` method to chaining middlewares:
@@ -98,6 +104,21 @@ const store = new Store(initialState)
98
104
.addMiddleware(mw2, mw3);
99
105
```
100
106
107
+
## Middleware example
108
+
109
+
This simple logger middleware logs the current- and the next state:
0 commit comments