June 2017
Intermediate to advanced
400 pages
8h 44m
English
Maybe is just like a Single except that it allows no emission to occur at all (hence Maybe). MaybeObserver is much like a standard Observer, but onNext() is called onSuccess() instead:
public interface MaybeObserver<T> { void onSubscribe(Disposable d); void onSuccess(T value); void onError(Throwable e); void onComplete(); }
A given Maybe<T> will only emit 0 or 1 emissions. 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 the single item. Maybe.empty() will create a Maybe that yields no emission:
import io.reactivex.Maybe; public class Launcher { public static void main(String[] args) { // has emission Maybe<Integer> presentSource ...
Read now
Unlock full access