如果我在subscribe内部多次订阅,那么第一次订阅中的complete()会等待吗



我的web中有多个数据要初始化,所以我创建了一个多订阅。

我的问题是,当没有发现错误时,第一个订阅会等待完成里面的所有订阅,直到它进入complete((吗?

这是的例子

myFirstService.subscribe(
data =>{
mySecondService.subscribe(
data =>{
codes
}
)
},
error =>{},
() => {}        <---------- will this () wait for the second service to finish?   
)

不,如果您想等待第二个可观察到的完成,您需要处理其中的逻辑。

示例:

myFirstService.subscribe(
data =>{
mySecondService.subscribe(
data =>{
codes
},
() => { // do stuff after second observable finishes }
)
},
error =>{},
() => {}        <---------- this will not wait for the second observable, only for the first   
)

最新更新