Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell that any object in a observable satisfies a condition?

Tags:

java

rx-java

I have looked and it seems like there is an "All" operation that will tell if all items satisfy a condition but no "Any" is this just an oversight or am I missing something? I could recreate it with other operations, but I could say the same thing with All.

Observable.just(1,5,10)
          .filter(i -> i < 7)
          .reduce((c,n) -> c && n) // or "||" for any
          .subscribe(b -> /* do stuff */);

Am I missing something or is there really just no Any?

like image 252
David Stocking Avatar asked Jan 21 '26 17:01

David Stocking


1 Answers

It was named exists in 1.x (and is again any in 2.x).

like image 129
akarnokd Avatar answered Jan 24 '26 05:01

akarnokd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!