【发布时间】:2018-12-06 21:56:23
【问题描述】:
我需要让一堆函数完成一些任务,并在最终函数中对结果做一些事情。
我在考虑使用异步/等待?
async function dosomething() {
// do stuff
// await till finished then grab the result
}
async function dosomethingelse() {
// do stuff
// await till finished then grab the result
}
function final() {
if (dosomething_result) {
// do something
}
etc...
}
所以基本上final() 在 dosomething 和 dosomethingelse 完成之前不会运行。
我希望我已经正确地解释了自己。
我的问题是......如果我的意思是这样做的话,我将如何使用 Async / Await 来做到这一点。
【问题讨论】:
-
绝对在
final中使用Promise.all
标签: javascript promise ecmascript-2017