1

I am trying to do the logical OR/AND operator on two observable Boolean values.

I looked around a little and found on some old questions that combineLatest could be used for that, but it seems unfortunately it is deprecated now, and I can't find any other way to accomplish the same task.

Just things which might or might not make what I seek easier. I need a way to apply OR operator on them in such a way that the resulting variable is also an observable Boolean and not just a Boolean (although this might work for me too).

Let me know what function or reference I can use to accomplish my task.

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Rishabh Agrawal
  • 101
  • 1
  • 1
  • 8
  • Please don't add tags that have nothing to do with your question. If you're working with RxJS, the way you combine things is the same in Angular as it is in React. It's all just JavaScript. Also, AngularJS !== Angular. The former is no longer maintained and permanently stuck prior to version 2. – Heretic Monkey Oct 17 '22 at 21:03

1 Answers1

4

combineLatest ain't deprecated, at least not the form taking an array as argument :

import { combineLatest, of, map } from 'rxjs'


combineLatest(
  [
    of(true),
    of(false)
  ]
)
  .pipe(
    map(([bool1, bool2]) => bool1 || bool2)
  )
  .subscribe(console.log)
Matthieu Riegler
  • 31,918
  • 20
  • 95
  • 134