public final class

SerializedObserver

extends Object
implements Observer<T> Disposable
java.lang.Object
   ↳ io.reactivex.observers.SerializedObserver<T>

Class Overview

Serializes access to the onNext, onError and 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.

Summary

Public Constructors
SerializedObserver(Observer<? super T> actual)
Construct a SerializedObserver by wrapping the given actual Observer.
SerializedObserver(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.
Public Methods
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(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(Disposable s)
Provides the Observer with the means of cancelling (disposing) the connection (channel) with the Observable in both synchronous (from within onNext(Object)) and asynchronous manner.
[Expand]
Inherited Methods
From class java.lang.Object
From interface io.reactivex.Observer
From interface io.reactivex.disposables.Disposable

Public Constructors

public SerializedObserver (Observer<? super T> actual)

Construct a SerializedObserver by wrapping the given actual Observer.

Parameters
actual the actual Observer, not null (not verified)

public SerializedObserver (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.

Parameters
actual the actual Observer, not null (not verified)
delayError if true, errors are emitted after regular values have been emitted

Public Methods

public void dispose ()

Dispose the resource, the operation should be idempotent.

public boolean isDisposed ()

Returns true if this resource has been disposed.

Returns
  • true if this resource has been disposed

public void onComplete ()

Notifies the Observer that the Observable has finished sending push-based notifications.

The Observable will not call this method if it calls onError(Throwable).

public void onError (Throwable t)

Notifies the Observer that the Observable has experienced an error condition.

If the Observable calls this method, it will not thereafter call onNext(T) or onComplete().

Parameters
t the exception encountered by the Observable

public void onNext (T t)

Provides the Observer 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 onComplete() or onError(Throwable).

Parameters
t the item emitted by the Observable

public void onSubscribe (Disposable s)

Provides the Observer with the means of cancelling (disposing) the connection (channel) with the Observable in both synchronous (from within onNext(Object)) and asynchronous manner.

Parameters
s the Disposable instance whose dispose() can be called anytime to cancel the connection