As far as I understand, in ES7/ES2016 putting multiple await 's in code will work similar to chaining .then() with promises, meaning that they will execute one after the other rather than in parallerl.(据我了解,在ES7 / ES2016中,在代码中放置多个await的工作方式类似于将带有.then()的承诺链接在一起,这意味着它们将一个接一个地执行而不是并行执行。)
await
.then()
await someCall(); await anotherCall();
anotherCall()
someCall()
You can await on Promise.all() :(您可以在Promise.all()上等待:)
Promise.all()
await Promise.all([someCall(), anotherCall()]);
let [someResult, anotherResult] = await Promise.all([someCall(), anotherCall()]);
1.4m articles
1.4m replys
5 comments
57.0k users