这个问题是关于 async/await 提议的。据我了解,以下功能:
async function foo() {
return await someAsyncFn();
await performSomeOtherAsyncAction();
doOneLastThing();
}
someAsyncFn() 解决后立即返回。
但是,如果没有返回值怎么办:
async function() {
await someAsyncFn();
await performSomeOtherAsyncAction();
doOneLastThing();
}
退出类似于以下的函数后返回的 Promise 是否立即解析:
function foo() {
someAsyncFn()
.then(() => {
return performSomeOtherAsyncAction();
})
.then(() => {
doOneLastThing();
});
}
还是等到内部承诺也像这样解决:
function foo() {
return someAsyncFn()
.then(() => {
return performSomeOtherAsyncAction();
})
.then(() => {
doOneLastThing();
});
}