我有多个承诺获取不同的资产。我想实现:
- 首先执行一些代码以通过
then()
. - 当一切都得到解决/获取时,执行一些通过
Promise.all().then()
.
我需要确保在 2 之前执行 1。从我测试的结果来看,它似乎确实有效。
// handle promises one by one
promise1.then(results => {});
promise2.then(results => {});
// common process that should come after the above then()s
Promise.all([promise1, promise2])
.then(results => {});
但我可以依赖它吗?“ single ”then()
总是在 a then()
on之前执行Promise.all()
吗?