Rxjs conditional switchMap based on a condition
问题 I have a situation like the following: myObservable1.pipe( switchMap((result1: MyObservable1) => { if (condition) { return myObservable2; } else { return of(null); } }) ).subscribe(myObservable1 | myObservable2) => { So if condition is false I only have to perform one request, if the condition is true, I have to chain the first request to the following one, they are essentially two requests to the server api. Is there a better solution without returning that null ? Is there any conditional