Class ScalarXMapZHelper

java.lang.Object
io.reactivex.rxjava3.internal.operators.mixed.ScalarXMapZHelper

final class ScalarXMapZHelper extends Object
Utility class to extract a value from a scalar source reactive type, map it to a 0-1 type then subscribe the output type's consumer to it, saving on the overhead of the regular subscription channel.

History: 2.1.11 - experimental

Since:
2.2
  • Constructor Details

    • ScalarXMapZHelper

      private ScalarXMapZHelper()
  • Method Details

    • tryAsCompletable

      static <T> boolean tryAsCompletable(Object source, Function<? super T,? extends CompletableSource> mapper, CompletableObserver observer)
      Try subscribing to a CompletableSource mapped from a scalar source (which implements Supplier).
      Type Parameters:
      T - the upstream value type
      Parameters:
      source - the source reactive type (Flowable or Observable) possibly implementing Supplier.
      mapper - the function that turns the scalar upstream value into a CompletableSource
      observer - the consumer to subscribe to the mapped CompletableSource
      Returns:
      true if a subscription did happen and the regular path should be skipped
    • tryAsMaybe

      static <T, R> boolean tryAsMaybe(Object source, Function<? super T,? extends MaybeSource<? extends R>> mapper, Observer<? super R> observer)
      Try subscribing to a MaybeSource mapped from a scalar source (which implements Supplier).
      Type Parameters:
      T - the upstream value type
      R - the downstream value type
      Parameters:
      source - the source reactive type (Flowable or Observable) possibly implementing Supplier.
      mapper - the function that turns the scalar upstream value into a MaybeSource
      observer - the consumer to subscribe to the mapped MaybeSource
      Returns:
      true if a subscription did happen and the regular path should be skipped
    • tryAsSingle

      static <T, R> boolean tryAsSingle(Object source, Function<? super T,? extends SingleSource<? extends R>> mapper, Observer<? super R> observer)
      Try subscribing to a SingleSource mapped from a scalar source (which implements Supplier).
      Type Parameters:
      T - the upstream value type
      R - the downstream value type
      Parameters:
      source - the source reactive type (Flowable or Observable) possibly implementing Supplier.
      mapper - the function that turns the scalar upstream value into a SingleSource
      observer - the consumer to subscribe to the mapped SingleSource
      Returns:
      true if a subscription did happen and the regular path should be skipped