1 回答

TA貢獻1818條經(jīng)驗 獲得超11個贊
dispatch(action) 等于 composedABC(action) 等于執(zhí)行 function A(action) {...}
在函數(shù) A 中執(zhí)行 next(action), 此時 A 中 next 為 composedBC,那么等于執(zhí)行 composedBC(action) 等于執(zhí)行function B(action){...}
在函數(shù) B 中執(zhí)行 next(action), 此時 B 中 next 為 composedC,那么等于執(zhí)行 composedC(action) 等于執(zhí)行function C(action){...}
在函數(shù) C 中執(zhí)行 next(action), 此時 C 中 next 為 store.dispatch 即 store 原生的 dispatch, 等于執(zhí)行store.dispatch(action)
store.dispatch 會執(zhí)行 reducer 生成最新的 store 數(shù)據(jù)
所有的 next 執(zhí)行完過后開始回溯
執(zhí)行函數(shù) C 中 next 后的代碼
執(zhí)行函數(shù) B 中 next 后的代碼
執(zhí)行函數(shù) A 中 next 后的代碼
整個執(zhí)行 action 的過程為 A -> B -> C -> dispatch -> C -> B -> A
- 1 回答
- 0 關(guān)注
- 774 瀏覽
添加回答
舉報