February 2020
Intermediate to advanced
412 pages
9h 36m
English
If you need to perform a calculation or some other action and then emit the result, you can use Observable.just() (or Single.just() or Maybe.just(), which we will present later). But sometimes, we want to do this in a lazy or deferred manner.
A word of caution: if that procedure throws an error, no emission (data or event) happens, and the exception propagates in the traditional Java fashion. For example, let's divide one by zero in it:
import io.reactivex.rxjava3.core.Observable;public class Ch2_26a { public static void main(String[] args) { Observable.just(1 / 0) .subscribe(i -> System.out.println("RECEIVED: " + i), e -> System.out.println("Error captured: " + e)); }}
The output is as follows:
Exception in thread ...
Read now
Unlock full access