Search code examples
angularrxjscombinelatest

RXJS - Angular : Two Observable<booleans> should return Observable<boolean>


I want to evaluate two observable<boolean> and I would like to save the flow in another observable<boolean>.

I tried combineLatest(obs1$, obs2$); but it generates an observable<[boolean, boolean]>.

Is there a better function than combineLatest to evaluate both observables and returns another observable<boolean>?


Solution

  • I think you could use forkJoin here and you'll need to map these two observables into one value using map operator.

    forkJoin([observable1, observable2]).pipe(
        map(([bool1, bool2]) => {
            return bool1 & bool2;
        })
    );