如果我在订阅中进行多个订阅,则第一次订阅中的complete是否会等待?

问题描述

我要在网络中初始化多个数据,所以我创建了多个订阅

我的问题是,在没有发现错误的情况下,第一个订阅是否会等待完成所有订阅,直到它进入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   
    )