RxJS sequence equivalent to promise.then()?

前端 未结 8 1401
南旧
南旧 2020-11-28 05:12

I used to develop a lot with promise and now I am moving to RxJS. The doc of RxJS doesn\'t provide a very clear example on how to move from promise chain to observer sequenc

8条回答
  •  日久生厌
    2020-11-28 05:15

    RxJS sequence equivalent to promise.then()?

    For example

    function getdata1 (argument) {
            return this.http.get(url)
                .map((res: Response) => res.json());
        }
    
        function getdata2 (argument) {
            return this.http.get(url)
                .map((res: Response) => res.json());
        }
    
        getdata1.subscribe((data1: any) => {
            console.log("got data one. get data 2 now");
            getdata2.subscribe((data2: any) => {
                console.log("got data one and two here");
            });
        });
    

提交回复
热议问题