T - the value typepublic final class SerializedObserver<T> extends Object implements Observer<T>, Disposable
Observer.onNext(Object), Observer.onError(Throwable) and
Observer.onComplete() methods of another Observer.
Note that onSubscribe(Disposable) is not serialized in respect of the other methods so
make sure the onSubscribe() is called with a non-null Disposable
before any of the other methods are called.
The implementation assumes that the actual Observer's methods don't throw.
| Constructor and Description |
|---|
SerializedObserver(@NonNull Observer<? super T> downstream)
Construct a
SerializedObserver by wrapping the given actual Observer. |
SerializedObserver(@NonNull Observer<? super T> actual,
boolean delayError)
Construct a SerializedObserver by wrapping the given actual
Observer and
optionally delaying the errors till all regular values have been emitted
from the internal buffer. |
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Dispose the resource, the operation should be idempotent.
|
boolean |
isDisposed()
Returns true if this resource has been disposed.
|
void |
onComplete()
Notifies the
Observer that the Observable has finished sending push-based notifications. |
void |
onError(@NonNull Throwable t)
Notifies the
Observer that the Observable has experienced an error condition. |
void |
onNext(T t)
Provides the
Observer with a new item to observe. |
void |
onSubscribe(@NonNull Disposable d)
Provides the
Observer with the means of cancelling (disposing) the
connection (channel) with the Observable in both
synchronous (from within Observer.onNext(Object)) and asynchronous manner. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdisposed, empty, fromAction, fromAutoCloseable, fromFuture, fromFuture, fromRunnable, fromSubscription, toAutoCloseablepublic SerializedObserver(@NonNull @NonNull Observer<? super T> downstream)
SerializedObserver by wrapping the given actual Observer.downstream - the actual Observer, not null (not verified)public SerializedObserver(@NonNull @NonNull Observer<? super T> actual, boolean delayError)
Observer and
optionally delaying the errors till all regular values have been emitted
from the internal buffer.actual - the actual Observer, not null (not verified)delayError - if true, errors are emitted after regular values have been emittedpublic void onSubscribe(@NonNull @NonNull Disposable d)
ObserverObserver with the means of cancelling (disposing) the
connection (channel) with the Observable in both
synchronous (from within Observer.onNext(Object)) and asynchronous manner.onSubscribe in interface Observer<T>d - the Disposable instance whose Disposable.dispose() can
be called anytime to cancel the connectionpublic void dispose()
Disposabledispose in interface Disposablepublic boolean isDisposed()
DisposableisDisposed in interface Disposablepublic void onNext(@NonNull T t)
ObserverObserver with a new item to observe.
The Observable may call this method 0 or more times.
The Observable will not call this method again after it calls either Observer.onComplete() or
Observer.onError(java.lang.Throwable).
public void onError(@NonNull @NonNull Throwable t)
ObserverObserver that the Observable has experienced an error condition.
If the Observable calls this method, it will not thereafter call Observer.onNext(T) or
Observer.onComplete().
public void onComplete()
ObserverObserver that the Observable has finished sending push-based notifications.
The Observable will not call this method if it calls Observer.onError(java.lang.Throwable).
onComplete in interface Observer<T>