February 2020
Intermediate to advanced
412 pages
9h 36m
English
The contains() operator checks whether a specified item (based on the hashCode()/equals() implementation) has been emitted by the source Observable. It returns a Single<Boolean> with true if the specified item was emitted, and false if it was not.
In the following code snippet, we emit the integers 1 through 10000, and we check whether the number 9563 is emitted from it using contains():
import io.reactivex.rxjava3.core.Observable;public class Ch3_28 { public static void main(String[] args) { Observable.range(1, 10000) .contains(9563) .subscribe(s -> System.out.println("Received: " + s)); }}
The output of the preceding code snippet is as follows:
Received: true
As you have probably guessed, the moment the specified value is found, ...
Read now
Unlock full access