February 2020
Intermediate to advanced
412 pages
9h 36m
English
The Maybe is just like a Single, except that it also allows no emissions to occur at all (hence Maybe). The MaybeObserver is much like a standard Observer, but onNext() is called onSuccess() instead:
public interface MaybeObserver<T> { void onSubscribe(@NonNull Disposable d); void onSuccess(T value); void onError@NonNull Throwable e); void onComplete();}
A given Maybe<T> emits 0 or 1 items. It will pass the possible emission to onSuccess(), and in either case, it will call onComplete() when done. Maybe.just() can be used to create a Maybe emitting a single item. Maybe.empty() creates a Maybe that emits nothing:
import io.reactivex.rxjava3.core.Maybe;public class Ch2_30a { public static void main(String[] args) { // has emission Maybe<Integer> ...
Read now
Unlock full access