February 2020
Intermediate to advanced
412 pages
9h 36m
English
The all() operator verifies that all emissions meet the specified criterion and returns a Single<Boolean> object. If they all pass, it returns the Single<Boolean> object that contains true. If it encounters one value that fails the criterion, it immediately calls onComplete() and returns the object that contains false. In the following code snippet, we test six (or fewer) integers, verifying that they all are less than 10:
import io.reactivex.rxjava3.core.Observable;public class Ch3_25 { public static void main(String[] args) { Observable.just(5, 3, 7, 11, 2, 14) .all(i -> i < 10) .subscribe(s -> System.out.println("Received: " + s)); }}
The output of the preceding code snippet is as follows:
Received: false
When the all() operator ...
Read now
Unlock full access