Class ObservablePublish<T>

java.lang.Object
io.reactivex.rxjava3.core.Observable<T>
io.reactivex.rxjava3.observables.ConnectableObservable<T>
io.reactivex.rxjava3.internal.operators.observable.ObservablePublish<T>
Type Parameters:
T - the element type
All Implemented Interfaces:
ObservableSource<T>, HasUpstreamObservableSource<T>

public final class ObservablePublish<T> extends ConnectableObservable<T> implements HasUpstreamObservableSource<T>
Shares a single underlying connection to the upstream ObservableSource and multicasts events to all subscribed observers until the upstream completes or the connection is disposed.

The difference to ObservablePublish is that when the upstream terminates, late observers will receive that terminal event until the connection is disposed and the ConnectableObservable is reset to its fresh state.

Since:
2.2.10
  • Field Details

  • Constructor Details

  • Method Details

    • connect

      public void connect(Consumer<? super Disposable> connection)
      Description copied from class: ConnectableObservable
      Instructs the ConnectableObservable to begin emitting the items from its underlying Observable to its Observers.
      Scheduler:
      The behavior is determined by the implementor of this abstract class.
      Specified by:
      connect in class ConnectableObservable<T>
      Parameters:
      connection - the action that receives the connection subscription before the subscription to source happens allowing the caller to synchronously disconnect a synchronous source
      See Also:
    • subscribeActual

      protected void subscribeActual(Observer<? super T> observer)
      Description copied from class: Observable
      Operator implementations (both source and intermediate) should implement this method that performs the necessary business logic and handles the incoming Observers.

      There is no need to call any of the plugin hooks on the current Observable instance or the Observer; all hooks and basic safeguards have been applied by Observable.subscribe(Observer) before this method gets called.

      Specified by:
      subscribeActual in class Observable<T>
      Parameters:
      observer - the incoming Observer, never null
    • reset

      public void reset()
      Description copied from class: ConnectableObservable
      Resets this ConnectableObservable into its fresh state if it has terminated or has been disposed.

      Calling this method on a fresh or active ConnectableObservable has no effect.

      Scheduler:
      The behavior is determined by the implementor of this abstract class.
      Specified by:
      reset in class ConnectableObservable<T>
    • source

      public ObservableSource<T> source()
      Description copied from interface: HasUpstreamObservableSource
      Returns the upstream source of this Observable.

      Allows discovering the chain of observables.

      Specified by:
      source in interface HasUpstreamObservableSource<T>
      Returns:
      the source ObservableSource