I currently have the following RxJS subscription :
combineLatest([obs1$, obs2$])
.pipe(
filter(val=>!!val[0] && !!val[1]), // ensuring no null values on both observables
switchMap(([val1, val2]) => combineLatest([of(v1), getObs3$(v2)]))
)
.subscribe(([val1, val3]) => { ... });
Although the code functions as intended, it seems a bit cumbersome. I am certain that the switchMap into combineLatest with an of() operator can be improved.
Note : To call getObs3$(v2)
, I need to ensure that there is a value in obs1$ first. Additionally, I require the val1 in the subscription as I will be using it later on.
Does anyone have any ideas on how to optimize this?