February 2020
Intermediate to advanced
412 pages
9h 36m
English
The Single<T> class is essentially an Observable<T> that emits only one item and, as such, is limited only to operators that make sense for a single emission. Similar to the Observable class (which implements ObservableSource), the Single class implements the SingleSource functional interface, which has only one method, void subscribe(SingleObserver observer).
There is the SingleObserver interface as well:
interface SingleObserver<T> { void onSubscribe(@NonNull Disposable d); void onSuccess(T value); void onError(@NonNull Throwable error);}
In contrast with the Observer interface, it does not have the onNext() method and has the onSuccess() method instead of onComplete(). This makes sense because Single can emit one value at the most. ...
Read now
Unlock full access