File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,7 +55,9 @@ Reduxの例として次のようなコードを見てみます。
5555dispatch(action) -> (_Middleware_ の処理) -> reducerにより新しいStateの作成 -> (Stateが変わったら) -> subscribeで登録したコールバックを呼ぶ
5656```
5757
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
5961
6062次は _ Middleware_ によりどのような拡張ができるのかを見ていきます。
6163
@@ -130,7 +132,10 @@ const middleware = (store) => {
130132
131133[ import, logger.js] ( ../../src/Redux/logger.js )
132134
133- - [ ] ログを挟んでいる図
135+
136+ この _ Middleware_ は次のようなイメージで動作します。
137+
138+ ![ dispatch-log.js flow] ( ./img/dispatch-log.js.png )
134139
135140この場合の ` next ` は ` dispatch ` と言い換えても問題ありませんが、複数の _ Middleware_ を適応した場合は、
136141** 次の** _ 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