Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文末enhancer执行顺序图 #17

Open
wenbin-ding opened this issue Mar 6, 2018 · 0 comments
Open

文末enhancer执行顺序图 #17

wenbin-ding opened this issue Mar 6, 2018 · 0 comments

Comments

@wenbin-ding
Copy link

原 createStore ————


return enhancer1(createStore)(reducer, preloadedState, enhancer2)
|
├———————→ createStore 增强版 1


return enhancer2(createStore1)(reducer, preloadedState, enhancer3)
|
├———————————→ createStore 增强版 1+2


return enhancer3(createStore1+2)(reducer, preloadedState, applyMiddleware(m1,m2,m3))
|
├————————————————————→ createStore 增强版 1+2+3


return appleMiddleware(m1,m2,m3)(createStore1+2+3)(reducer, preloadedState)
|
├——————————————————————————————————→ 生成最终增强版 store

感觉图中enhancer的第二次调用应该去掉吧。因为createStore调用的是compose返回的函数(称func),func被调用让enhancer被串联执行,在这个过程中,enhancer应该只有一次调用,func(createStore) => enhancer(createStore),后面的第二次调用应该是所有enhaner执行完成,返回最终版store,在原始createStore内,执行finalCreateStore(reducer, preloadedState)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant