javascript - 使用 Reflux Actions 等待完成多个请求
问题描述
首先,初始化应用程序。我调用了许多 Async Reflux Actions 请求:
ExpenActions.loadAccounts();
WareActions.load();
ProdActions.load();
NotifActions.load();
所有请求都是这样创建的:
import Reflux from 'reflux';
const WareActions = Reflux.createActions({
load: { asyncResult: true },
});
onLoad() {
console.log("start load...")
return yajax.get(this._prefix+'warehouse/get').then(
Actions.load.completed,
Actions.load.failed);
},
onLoadCompleted(data) {
console.log("completed load", data);
this.setState({
rows: (data.success) ? data.data : [],
isLoaded: false
})
},
onLoadFailed() {
console.log("failed load");
},
我可以分别等待每个请求..但是如何在所有事件完成后挂起一个事件?
Promise.all
不起作用..因为WareActions.load()
返回未定义...不是Promise
..
解决方案
推荐阅读
- excel - 具有不同行和列中可用条件的 Excel 条件查找
- javascript - forEach 中的 EventLister 参数需要错误(工具提示)
- actionscript-3 - Animate 2021 动作脚本 3 URLRequest 导致错误 2035
- ios - DispatchQueue 线程并不总是设置正确的结果
- python - 通过 Gunicorn 运行 Flask Restplus API
- java - 如何拼贴预订日期输入并以 LocalDate 格式返回,并使用布尔值验证年/月/日值?
- javascript - 如何将多个链接添加到图像的某些部分
- python - 如何在数据框中查找具有相同行名的两个单元格的总和(熊猫)
- r - 在 R 中聚合列数据
- dropdown - 如何在 Angular 中实现 2 个相互依赖的多选下拉列表?