Class ObservableReplay<T>

java.lang.Object
io.reactivex.rxjava3.core.Observable<T>
io.reactivex.rxjava3.observables.ConnectableObservable<T>
io.reactivex.rxjava3.internal.operators.observable.ObservableReplay<T>
All Implemented Interfaces:
ObservableSource<T>, HasUpstreamObservableSource<T>

public final class ObservableReplay<T> extends ConnectableObservable<T> implements HasUpstreamObservableSource<T>
  • Field Details

  • Constructor Details

  • Method Details

    • multicastSelector

      public static <U, R> Observable<R> multicastSelector(Supplier<? extends ConnectableObservable<U>> connectableFactory, Function<? super Observable<U>,? extends ObservableSource<R>> selector)
      Given a connectable observable factory, it multicasts over the generated ConnectableObservable via a selector function.
      Type Parameters:
      U - the value type of the ConnectableObservable
      R - the result value type
      Parameters:
      connectableFactory - the factory that returns a ConnectableObservable for each individual subscriber
      selector - the function that receives an Observable and should return another Observable that will be subscribed to
      Returns:
      the new Observable instance
    • createFrom

      public static <T> ConnectableObservable<T> createFrom(ObservableSource<? extends T> source)
      Creates a replaying ConnectableObservable with an unbounded buffer.
      Type Parameters:
      T - the value type
      Parameters:
      source - the source observable
      Returns:
      the new ConnectableObservable instance
    • create

      public static <T> ConnectableObservable<T> create(ObservableSource<T> source, int bufferSize, boolean eagerTruncate)
      Creates a replaying ConnectableObservable with a size bound buffer.
      Type Parameters:
      T - the value type
      Parameters:
      source - the source ObservableSource to use
      bufferSize - the maximum number of elements to hold
      eagerTruncate - if true, the head reference is refreshed to avoid unwanted item retention
      Returns:
      the new ConnectableObservable instance
    • create

      public static <T> ConnectableObservable<T> create(ObservableSource<T> source, long maxAge, TimeUnit unit, Scheduler scheduler, boolean eagerTruncate)
      Creates a replaying ConnectableObservable with a time bound buffer.
      Type Parameters:
      T - the value type
      Parameters:
      source - the source ObservableSource to use
      maxAge - the maximum age of entries
      unit - the unit of measure of the age amount
      scheduler - the target scheduler providing the current time
      eagerTruncate - if true, the head reference is refreshed to avoid unwanted item retention
      Returns:
      the new ConnectableObservable instance
    • create

      public static <T> ConnectableObservable<T> create(ObservableSource<T> source, long maxAge, TimeUnit unit, Scheduler scheduler, int bufferSize, boolean eagerTruncate)
      Creates a replaying ConnectableObservable with a size and time bound buffer.
      Type Parameters:
      T - the value type
      Parameters:
      source - the source ObservableSource to use
      maxAge - the maximum age of entries
      unit - the unit of measure of the age amount
      scheduler - the target scheduler providing the current time
      bufferSize - the maximum number of elements to hold
      eagerTruncate - if true, the head reference is refreshed to avoid unwanted item retention
      Returns:
      the new ConnectableObservable instance
    • create

      static <T> ConnectableObservable<T> create(ObservableSource<T> source, ObservableReplay.BufferSupplier<T> bufferFactory)
      Creates a OperatorReplay instance to replay values of the given source observable.
      Type Parameters:
      T - the value type
      Parameters:
      source - the source observable
      bufferFactory - the factory to instantiate the appropriate buffer when the observable becomes active
      Returns:
      the connectable observable
    • 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
    • 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>
    • 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
    • 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: