June 2017
Intermediate to advanced
400 pages
8h 44m
English
The any() method will check whether at least one emission meets a specific criterion and return a Single<Boolean>. The moment it finds an emission that qualifies, it will emit true and then call onComplete(). If it processes all emissions and finds that they all are false, it will emit false and call onComplete().
In the following code snippet, we emit four date strings, convert them into LocalDate emissions, and test for any that are in the month of June or later:
import io.reactivex.Observable;import java.time.LocalDate;public class Launcher { public static void main(String[] args) { Observable.just("2016-01-01", "2016-05-02", "2016-09-12", "2016-04-03") .map(LocalDate::parse) .any(dt -> dt.getMonthValue() >= 6) .subscribe(s ->
Read now
Unlock full access