T
- the value type received and emittedpublic final class SingleSubject<T> extends Single<T> implements SingleObserver<T>
All methods are thread safe. Calling onSuccess multiple times has no effect. Calling onError multiple times relays the Throwable to the RxJavaPlugins' error handler.
The SingleSubject doesn't store the Disposables coming through onSubscribe but disposes them once the other onXXX methods were called (terminal state reached).
Modifier and Type | Method and Description |
---|---|
static <T> SingleSubject<T> |
create()
Creates a fresh SingleSubject.
|
java.lang.Throwable |
getThrowable()
Returns the terminal error if this SingleSubject has been terminated with an error, null otherwise.
|
T |
getValue()
Returns the success value if this SingleSubject was terminated with a success value.
|
boolean |
hasObservers()
Returns true if this SingleSubject has observers.
|
boolean |
hasThrowable()
Returns true if this SingleSubject has been terminated with an error.
|
boolean |
hasValue()
Returns true if this SingleSubject was terminated with a success value.
|
void |
onError(java.lang.Throwable e)
Notifies the SingleObserver that the
Single has experienced an error condition. |
void |
onSubscribe(Disposable d)
Provides the SingleObserver with the means of cancelling (disposing) the
connection (channel) with the Single in both
synchronous (from within
onSubscribe(Disposable) itself) and asynchronous manner. |
void |
onSuccess(T value)
Notifies the SingleObserver with a single item and that the
Single has finished sending
push-based notifications. |
protected void |
subscribeActual(SingleObserver<? super T> observer)
Override this method in subclasses to handle the incoming SingleObservers.
|
amb, ambArray, ambWith, blockingGet, cache, cast, compose, concat, concat, concat, concat, concat, concat, concat, concatArray, concatWith, contains, contains, create, defer, delay, delay, delaySubscription, delaySubscription, delaySubscription, delaySubscription, delaySubscription, delaySubscription, doAfterSuccess, doAfterTerminate, doFinally, doOnDispose, doOnError, doOnEvent, doOnSubscribe, doOnSuccess, equals, error, error, filter, flatMap, flatMapCompletable, flatMapMaybe, flatMapObservable, flatMapPublisher, flattenAsFlowable, flattenAsObservable, fromCallable, fromFuture, fromFuture, fromFuture, fromFuture, fromObservable, fromPublisher, hide, just, lift, map, merge, merge, merge, merge, merge, merge, mergeWith, never, observeOn, onErrorResumeNext, onErrorResumeNext, onErrorReturn, onErrorReturnItem, repeat, repeat, repeatUntil, repeatWhen, retry, retry, retry, retry, retryWhen, subscribe, subscribe, subscribe, subscribe, subscribe, subscribeOn, subscribeWith, takeUntil, takeUntil, takeUntil, test, test, timeout, timeout, timeout, timeout, timer, timer, to, toCompletable, toFlowable, toFuture, toMaybe, toObservable, unsafeCreate, using, using, wrap, zip, zip, zip, zip, zip, zip, zip, zip, zip, zipArray, zipWith
@CheckReturnValue public static <T> SingleSubject<T> create()
T
- the value type received and emittedpublic void onSubscribe(Disposable d)
SingleObserver
onSubscribe(Disposable)
itself) and asynchronous manner.onSubscribe
in interface SingleObserver<T>
d
- the Disposable instance whose Disposable.dispose()
can
be called anytime to cancel the connectionpublic void onSuccess(T value)
SingleObserver
Single
has finished sending
push-based notifications.
The Single
will not call this method if it calls SingleObserver.onError(java.lang.Throwable)
.
onSuccess
in interface SingleObserver<T>
value
- the item emitted by the Singlepublic void onError(java.lang.Throwable e)
SingleObserver
Single
has experienced an error condition.
If the Single
calls this method, it will not thereafter call SingleObserver.onSuccess(T)
.
onError
in interface SingleObserver<T>
e
- the exception encountered by the Singleprotected void subscribeActual(SingleObserver<? super T> observer)
Single
subscribeActual
in class Single<T>
observer
- the SingleObserver to handle, not nullpublic T getValue()
public boolean hasValue()
public java.lang.Throwable getThrowable()
public boolean hasThrowable()
public boolean hasObservers()