我对 redux 的真实示例有几个问题。
与直接使用 dispatch 进行 ajax 调用的异步示例不同,实际示例使用中间件来处理此问题。在 react 应用程序中使用 redux 时推荐哪种方法?为什么?
我的猜测是中间件是可重用的,所以如果需要进行多个ajax调用,只要传入不同的api路径作为参数,一个通用的ajax调用中间件就足够了。但是同样的事情也可以用 dispatch 说...
中间件什么时候执行?通过查看源代码和阅读文档,我的理解是:
dispatch an action -> all middlewares get executed , ajax calls can be made here and the returned json data can be put inside the action object and pass it onto the reducers-> reducers get executed
. 我对么?