February 2020
Intermediate to advanced
412 pages
9h 36m
English
The any() method checks whether at least one emission meets a specified criterion and returns a Single<Boolean>. The moment it finds an emission that does, it returns a Single<Boolean> object with true and then calls onComplete(). If it processes all emissions and finds that none of them meet the criterion, it returns a Single<Boolean> object with false and calls onComplete().
In the following code snippet, we emit four date strings, convert them into the LocalDate type, and check whether any are in the month of June or later:
import io.reactivex.rxjava3.core.Observable;import java.time.LocalDate;public class Ch3_26 { public static void main(String[] args) { Observable.just("2016-01-01", "2016-05-02", "2016-09-12", "2016-04-03") .map(LocalDate:: ...
Read now
Unlock full access