Rxjs conditional switchMap based on a condition
Another possibility is to use the operator iif in a SwitchMap. https://www.learnrxjs.io/learn-rxjs/operators/conditional/iif https://rxjs-dev.firebaseapp.com/api/index/function/iif but it can restrain the possibility to control specfic conditions on your Observable : myObservable1 .pipe( switchMap(result1 => iif(() => condition , myObservable2 , myObservable1 ) ) .subscribe(result => console.log(result)); Where you can replace ‘condition’ by a function returning a boolean. With … Read more