关闭
也许我的问题有点复杂,但我不知道如何实现我想要的。
上下文
三个并行可观察量发出值,然后,当我拥有所有三个值时,我对它们进行一些修改,然后我想串联调用三个可观察量。就像下图一样:
现在?
目前,我设法通过将三个并行可观察量放入zip运算符中来做到这一点,然后订阅它,修改值,完成后调用另一个,订阅,然后完成......三次!
this.service.Function(id) //return zip(Ob1, Ob2, Ob3)
.subscribe(
([val1, val2, val3]) => {
/*DO SOMETHING*/
this.tmp1 = val1;
this.tmp2 = val2;
this.tmp3 = val3;
},
() => {}, //on error
() => { //on complete
let newV1, newV2, newV3 = [];
[newV1, newV2, newV3 ] = [
this.tmp1.map(x => x.id2),
this.tmp2.map(x => x.id2),
this.tmp3.map(x => x.id2)
];
this.service.Function2(newV1)
.subscribe(res => {
//DO SOMETHING
},
() => {},
() => { //on complete
this.service.Function2(newV2)
.subscribe(res …
Run Code Online (Sandbox Code Playgroud)