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.

1
  • 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. Commented Oct 17, 2022 at 21:03

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.