【发布时间】:2021-11-07 05:16:30
【问题描述】:
我有一个调用其他函数的辅助函数。我希望调用的函数在继续使用辅助函数之前完成。
目前他们都在同时改变事物。
helperDikjstras = async() => {
//do stuff
await this.colorVisited(visitedNodes); // I want this function to finish before continuing
await this.colorPath(path);
//EDIT: I've also tried:
this.colorVisited(visitedNodes).then(() => this.colorPath(path));
return;
}
colorVisited = async (visitedNodes) => {
//do stuff
return;
}
colorPath = async (path) => {
//do stuff
return;
}
【问题讨论】:
-
仅供参考:JavaScript 中隐含了空的
return语句 - 无需添加return;
标签: javascript asynchronous async-await