Class SerializedObserver<T>

java.lang.Object
io.reactivex.rxjava3.observers.SerializedObserver<T>
Type Parameters:
T - the value type
All Implemented Interfaces:
Observer<T>, Disposable

public final class SerializedObserver<T> extends Object implements Observer<T>, Disposable
Serializes access to the 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.

  • Field Details

  • Constructor Details

    • SerializedObserver

      public SerializedObserver(@NonNull @NonNull Observer<? super T> downstream)
      Construct a SerializedObserver by wrapping the given actual Observer.
      Parameters:
      downstream - the actual Observer, not null (not verified)
    • SerializedObserver

      public SerializedObserver(@NonNull @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.
      Parameters:
      actual - the actual Observer, not null (not verified)
      delayError - if true, errors are emitted after regular values have been emitted
  • Method Details