【发布时间】:2020-07-13 01:14:42
【问题描述】:
我在每个循环中都有一个嵌套订阅,其中内部订阅将外部订阅的结果作为输入。我需要代码像在 for 循环中迭代时一样,它应该调用外部订阅并将其结果/输出传递给内部订阅。这里的 for 循环应该等到该过程完成后再进行下一次迭代。这里我提供了一个演示
this.forVar.forEach(item =>{
this.service.outerSubscribe(item).subscribe(res=>{
//some coding here
this.service.innerSubscribe(res).subscribe(res1=>{//some coding here});
});
//for each should iterate only after both subscribes are executed.
});
【问题讨论】: