在我的角度应用程序中,我使用承诺在我的服务中调用方法,但由于我需要多次调用它,因此我在for循环中调用它。多次呼叫承诺
for(let item of this.arrayName)
{
this.service.funcName(item.name).then(result => {
//handle result
}).catch(err => {
//handle error
});
}
但是当从多个调用同时获得结果时会发生什么?承诺知道如何处理它?它是否分别处理每个结果? 还是我需要锁定代码? 在此先感谢。
你不能“呼吁承诺”。您可以调用返回承诺的函数。每个调用将(可能)返回一个单独的承诺。 – 2017-06-29 12:30:40