Reputation: 1905
I need to fix this nested subscriptions , but i have some difficulties :-( could you help me please to find a solution?
combineLatest([stream1,stream2])
.pipe(takeUntil(this.destroyed$))
.subscribe({
next: ([a, b]) => {
this.extService.get(a,b).subscribe();
},
});
Upvotes: -1
Views: 488
Reputation: 844
In this case you would have to use switch map after, this way it will "change" to the new subscription
combineLatest([stream1,stream2])
.pipe(
takeUntil(this.destroyed$),
switchMap(([a,b])=>this.extService.get(a,b)
)
)
.subscribe(
(responseFromExtService) => { // your code}
);
Make sure you know also the difference between combine lastest and fork join
Upvotes: 5