store.dispatch是Redux同步还是异步 [英] Is store.dispatch in Redux synchronous or asynchronous
问题描述
我意识到这是一个基本问题,但我没有在其他地方找到答案。
I realize this is a basic question but I had no luck finding the answer elsewhere.
store.dispatch
同步或异步 Redux
?
如果它是异步的,有可能在之后添加回调 React
?
In case it is asynchronous is there a possibility to add a callback after the action has been propagated as it is possible with React
?
推荐答案
AFAIK,调度动作是同步的。如果您愿意解决异步调用,可以在redux中使用 thunk-middleware ,dispatch作为回调函数提供,您可以根据自己的方便调用它。有关详细信息,请通过作者本身在SO上查看此答案:如何使用超时发送Redux操作?
AFAIK, dispatching action is synchronous. In case if you are willing to address the asynchronous call, you can use the thunk-middleware in redux, where dispatch is provided as a callback function which you can invoke as per your convenience. For more info, checkout this answer on SO by Author itself: How to dispatch a Redux action with a timeout?
这篇关于store.dispatch是Redux同步还是异步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!