June 2017
Intermediate to advanced
400 pages
8h 44m
English
The all() operator verifies that each emission qualifies with a specified condition and return a Single<Boolean>. If they all pass, it will emit True. If it encounters one that fails, it will immediately emit False. In the following code snippet, we emit a test against six integers, verifying that they all are less than 10:
import io.reactivex.Observable;public class Launcher { 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 encountered 11, it immediately emitted False and called onComplete(). It did not even get to 2 or 14 because that ...
Read now
Unlock full access