File tree Expand file tree Collapse file tree 4 files changed +27
-2
lines changed Expand file tree Collapse file tree 4 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,9 @@ Reduxの例として次のようなコードを見てみます。
55
55
dispatch(action) -> (_Middleware_ の処理) -> reducerにより新しいStateの作成 -> (Stateが変わったら) -> subscribeで登録したコールバックを呼ぶ
56
56
```
57
57
58
- - [ ] 図にしたほうがいい
58
+ ![ Redux flow] ( ./img/redux-unidir-ui-arch.jpg )
59
+
60
+ via [ staltz.com/unidirectional-user-interface-architectures.html] ( http://staltz.com/unidirectional-user-interface-architectures.html ) o
59
61
60
62
次は _ Middleware_ によりどのような拡張ができるのかを見ていきます。
61
63
@@ -130,7 +132,10 @@ const middleware = (store) => {
130
132
131
133
[ import, logger.js] ( ../../src/Redux/logger.js )
132
134
133
- - [ ] ログを挟んでいる図
135
+
136
+ この _ Middleware_ は次のようなイメージで動作します。
137
+
138
+ ![ dispatch-log.js flow] ( ./img/dispatch-log.js.png )
134
139
135
140
この場合の ` next ` は ` dispatch ` と言い換えても問題ありませんが、複数の _ Middleware_ を適応した場合は、
136
141
** 次の** _ Middleware_ を呼び出すという事を表現しています。
Original file line number Diff line number Diff line change
1
+ // dispatch action
2
+ const action = {type: "ActionType"};
3
+ dispatch(action);
4
+ // |
5
+ // |
6
+ // v
7
+ // logger middleware
8
+ // | "action"
9
+ // v
10
+ store => next => action => {
11
+ logger.log(action);
12
+ const value = next(action);
13
+ // next is store.dispatch
14
+ logger.log(store.getState());
15
+ return value;
16
+ }
17
+ // |
18
+ // |
19
+ // v
20
+ store.dispatch(action);
You can’t perform that action at this time.
0 commit comments