我要在网络中初始化多个数据,所以我创建了多个订阅。
我的问题是,在没有发现错误的情况下,第一个订阅是否会等待完成所有订阅,直到它进入complete()?
这是例子
myFirstService.subscribe(
data =>{
mySecondService.subscribe(
data =>{
codes
}
)
},
error =>{},
() => {} <---------- will this () wait for the second service to finish?
)
答案 0 :(得分:0)
否,如果要等待第二个可观察对象完成,则需要在其中处理逻辑。
示例:
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
)