Class ObservableTransformers

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T,​R>
      ObservableTransformer<T,​R>
      errorJump​(ObservableTransformer<T,​R> transformer)
      Allows an upstream error to jump over an inner transformation and is then reapplied once the inner transformation's returned Flowable terminates.
      static <T> ObservableTransformer<T,​T> filterAsync​(Function<? super T,​? extends ObservableSource<java.lang.Boolean>> asyncPredicate)
      Maps each upstream value into a single true or false value provided by a generated ObservableSource for that input value and emits the input value if the inner ObservableSource returned true.
      static <T> ObservableTransformer<T,​T> filterAsync​(Function<? super T,​? extends ObservableSource<java.lang.Boolean>> asyncPredicate, int bufferSize)
      Maps each upstream value into a single true or false value provided by a generated ObservableSource for that input value and emits the input value if the inner ObservableSource returned true.
      static <T,​R>
      @NonNull ObservableTransformer<T,​R>
      flatMapDrop​(Function<? super T,​? extends ObservableSource<? extends R>> mapper)
      FlatMap only one ObservableSource at a time and ignore upstream values until it terminates.
      static <T,​R>
      @NonNull ObservableTransformer<T,​R>
      flatMapLatest​(Function<? super T,​? extends ObservableSource<? extends R>> mapper)
      FlatMap only one ObservableSource at a time and keep the latest upstream value until it terminates and resume with the ObservableSource mapped for that latest upstream value.
      static <T> @NonNull ObservableTransformer<T,​java.lang.Long> indexOf​(@NonNull Predicate<? super T> predicate)
      Returns the first index of an element that matches a predicate or -1L if no elements match.
      static <T,​R>
      ObservableTransformer<T,​R>
      mapAsync​(Function<? super T,​? extends ObservableSource<? extends R>> mapper)
      Maps each upstream value into a single value provided by a generated ObservableSource for that input value, which is then emitted to the downstream.
      static <T,​R>
      ObservableTransformer<T,​R>
      mapAsync​(Function<? super T,​? extends ObservableSource<? extends R>> mapper, int capacityHint)
      Maps each upstream value into a single value provided by a generated ObservableSource for that input value, which is then emitted to the downstream.
      static <T,​U,​R>
      ObservableTransformer<T,​R>
      mapAsync​(Function<? super T,​? extends ObservableSource<? extends U>> mapper, BiFunction<? super T,​? super U,​? extends R> combiner)
      Maps each upstream value into a single value provided by a generated ObservableSource for that input value and combines the original and generated single value into a final result item to be emitted to downstream.
      static <T,​U,​R>
      ObservableTransformer<T,​R>
      mapAsync​(Function<? super T,​? extends ObservableSource<? extends U>> mapper, BiFunction<? super T,​? super U,​? extends R> combiner, int capacityHint)
      Maps each upstream value into a single value provided by a generated ObservableSource for that input value and combines the original and generated single value into a final result item to be emitted to downstream.
      static <T> @NonNull ObservableTransformer<T,​T> observeOnDrop​(@NonNull Scheduler scheduler)
      Schedules the event emission on a Scheduler and drops upstream values while the onNext with the current item is executing on that scheduler.
      static <T> @NonNull ObservableTransformer<T,​T> observeOnLatest​(@NonNull Scheduler scheduler)
      Schedules the event emission on a Scheduler and keeps the latest upstream item while the downstream's onNext is executing so that it will resume with that latest value.
      static <T> ObservableTransformer<T,​T> valve​(ObservableSource<java.lang.Boolean> other)
      Relays values until the other ObservableSource signals false and resumes if the other ObservableSource signals true again, like closing and opening a valve and not losing any items from the main source.
      static <T> ObservableTransformer<T,​T> valve​(ObservableSource<java.lang.Boolean> other, boolean defaultOpen)
      Relays values until the other ObservableSource signals false and resumes if the other ObservableSource signals true again, like closing and opening a valve and not losing any items from the main source and starts with the specified valve state.
      static <T> ObservableTransformer<T,​T> valve​(ObservableSource<java.lang.Boolean> other, boolean defaultOpen, int bufferSize)
      Relays values until the other ObservableSource signals false and resumes if the other ObservableSource signals true again, like closing and opening a valve and not losing any items from the main source and starts with the specified valve state and the specified buffer size hint.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • indexOf

        @SchedulerSupport("none")
        @CheckReturnValue
        @NonNull
        public static <T> @NonNull ObservableTransformer<T,​java.lang.Long> indexOf​(@NonNull
                                                                                         @NonNull Predicate<? super T> predicate)
        Returns the first index of an element that matches a predicate or -1L if no elements match.
        Type Parameters:
        T - the upstream element type
        Parameters:
        predicate - the predicate called to test each item, returning true will stop the sequence and return the current item index
        Returns:
        the new ObservableTransformer instance
        Since:
        0.18.2
      • flatMapDrop

        @SchedulerSupport("none")
        @CheckReturnValue
        @NonNull
        public static <T,​R> @NonNull ObservableTransformer<T,​R> flatMapDrop​(Function<? super T,​? extends ObservableSource<? extends R>> mapper)
        FlatMap only one ObservableSource at a time and ignore upstream values until it terminates.

        Errors are delayed until both the upstream and the active inner ObservableSource terminate.

        Type Parameters:
        T - the upstream value type
        R - the output type
        Parameters:
        mapper - the function that takes an upstream item and returns a ObservableSource to be run exclusively until it finishes
        Returns:
        the new ObservableTransformer instance
        Since:
        0.19.0
      • flatMapLatest

        @SchedulerSupport("none")
        @CheckReturnValue
        @NonNull
        public static <T,​R> @NonNull ObservableTransformer<T,​R> flatMapLatest​(Function<? super T,​? extends ObservableSource<? extends R>> mapper)
        FlatMap only one ObservableSource at a time and keep the latest upstream value until it terminates and resume with the ObservableSource mapped for that latest upstream value.

        Errors are delayed until both the upstream and the active inner ObservableSource terminate.

        Type Parameters:
        T - the upstream value type
        R - the output type
        Parameters:
        mapper - the function that takes an upstream item and returns a ObservableSource to be run exclusively until it finishes
        Returns:
        the new ObservableTransformer instance
        Since:
        0.19.0
      • errorJump

        public static <T,​R> ObservableTransformer<T,​R> errorJump​(ObservableTransformer<T,​R> transformer)
        Allows an upstream error to jump over an inner transformation and is then reapplied once the inner transformation's returned Flowable terminates.
        Type Parameters:
        T - the upstream value type
        R - the downstream value type
        Parameters:
        transformer - the transformation applied to the flow on a per-Subscriber basis
        Returns:
        the new FlowableTransformer instance
        Since:
        0.19.1
      • valve

        @SchedulerSupport("none")
        public static <T> ObservableTransformer<T,​T> valve​(ObservableSource<java.lang.Boolean> other)
        Relays values until the other ObservableSource signals false and resumes if the other ObservableSource signals true again, like closing and opening a valve and not losing any items from the main source.

        Properties:

        • The operator starts with an open valve.
        • If the other ObservableSource completes, the sequence terminates with an IllegalStateException.
        • The operator doesn't run on any particular Scheduler.
        • The operator uses an internal unbounded buffer of size Flowable.bufferSize() to hold onto values if the valve is closed.
        Type Parameters:
        T - the value type of the main source
        Parameters:
        other - the other source
        Returns:
        the new ObservableTransformer instance
        Throws:
        java.lang.NullPointerException - if other is null
        Since:
        0.20.2
      • valve

        @SchedulerSupport("none")
        public static <T> ObservableTransformer<T,​T> valve​(ObservableSource<java.lang.Boolean> other,
                                                                 boolean defaultOpen)
        Relays values until the other ObservableSource signals false and resumes if the other ObservableSource signals true again, like closing and opening a valve and not losing any items from the main source and starts with the specified valve state.

        Properties:

        • If the other ObservableSource completes, the sequence terminates with an IllegalStateException.
        • The operator doesn't run on any particular Scheduler.
        • The operator uses an internal unbounded buffer of size Flowable.bufferSize() to hold onto values if the valve is closed.
        Type Parameters:
        T - the value type of the main source
        Parameters:
        other - the other source
        defaultOpen - should the valve start as open?
        Returns:
        the new ObservableTransformer instance
        Throws:
        java.lang.NullPointerException - if other is null
        Since:
        0.20.2
      • valve

        @SchedulerSupport("none")
        public static <T> ObservableTransformer<T,​T> valve​(ObservableSource<java.lang.Boolean> other,
                                                                 boolean defaultOpen,
                                                                 int bufferSize)
        Relays values until the other ObservableSource signals false and resumes if the other ObservableSource signals true again, like closing and opening a valve and not losing any items from the main source and starts with the specified valve state and the specified buffer size hint.

        Properties:

        • If the other ObservableSource completes, the sequence terminates with an IllegalStateException.
        • The operator doesn't run on any particular Scheduler.
        Type Parameters:
        T - the value type of the main source
        Parameters:
        other - the other source
        defaultOpen - should the valve start as open?
        bufferSize - the buffer size hint (the chunk size of the underlying unbounded buffer)
        Returns:
        the new ObservableTransformer instance
        Throws:
        java.lang.IllegalArgumentException - if bufferSize <= 0
        java.lang.NullPointerException - if other is null
        Since:
        0.20.2
      • mapAsync

        public static <T,​R> ObservableTransformer<T,​R> mapAsync​(Function<? super T,​? extends ObservableSource<? extends R>> mapper)
        Maps each upstream value into a single value provided by a generated ObservableSource for that input value, which is then emitted to the downstream.

        Only the first item emitted by the inner ObservableSource are considered. If the inner ObservableSource is empty, no resulting item is generated for that input value.

        The inner ObservableSources are consumed in order and one at a time.

        Type Parameters:
        T - the input value type
        R - the result value type
        Parameters:
        mapper - the function that receives the upstream value and returns a ObservableSource that should emit a single value to be emitted.
        Returns:
        the new ObservableTransformer instance
        Since:
        0.20.4
      • mapAsync

        public static <T,​R> ObservableTransformer<T,​R> mapAsync​(Function<? super T,​? extends ObservableSource<? extends R>> mapper,
                                                                            int capacityHint)
        Maps each upstream value into a single value provided by a generated ObservableSource for that input value, which is then emitted to the downstream.

        Only the first item emitted by the inner ObservableSource are considered. If the inner ObservableSource is empty, no resulting item is generated for that input value.

        The inner ObservableSources are consumed in order and one at a time.

        Type Parameters:
        T - the input value type
        R - the result value type
        Parameters:
        mapper - the function that receives the upstream value and returns a ObservableSource that should emit a single value to be emitted.
        capacityHint - the number of items expected from the upstream to be buffered while each inner ObservableSource is executing.
        Returns:
        the new ObservableTransformer instance
        Since:
        0.20.4
      • mapAsync

        public static <T,​U,​R> ObservableTransformer<T,​R> mapAsync​(Function<? super T,​? extends ObservableSource<? extends U>> mapper,
                                                                                    BiFunction<? super T,​? super U,​? extends R> combiner)
        Maps each upstream value into a single value provided by a generated ObservableSource for that input value and combines the original and generated single value into a final result item to be emitted to downstream.

        Only the first item emitted by the inner ObservableSource are considered. If the inner ObservableSource is empty, no resulting item is generated for that input value.

        The inner ObservableSources are consumed in order and one at a time.

        Type Parameters:
        T - the input value type
        U - the intermediate value type
        R - the result value type
        Parameters:
        mapper - the function that receives the upstream value and returns a ObservableSource that should emit a single value to be emitted.
        combiner - the bi-function that receives the original upstream value and the single value emitted by the ObservableSource and returns a result value to be emitted to downstream.
        Returns:
        the new ObservableTransformer instance
        Since:
        0.20.4
      • mapAsync

        public static <T,​U,​R> ObservableTransformer<T,​R> mapAsync​(Function<? super T,​? extends ObservableSource<? extends U>> mapper,
                                                                                    BiFunction<? super T,​? super U,​? extends R> combiner,
                                                                                    int capacityHint)
        Maps each upstream value into a single value provided by a generated ObservableSource for that input value and combines the original and generated single value into a final result item to be emitted to downstream.

        Only the first item emitted by the inner ObservableSource are considered. If the inner ObservableSource is empty, no resulting item is generated for that input value.

        The inner ObservableSources are consumed in order and one at a time.

        Type Parameters:
        T - the input value type
        U - the intermediate value type
        R - the result value type
        Parameters:
        mapper - the function that receives the upstream value and returns a ObservableSource that should emit a single value to be emitted.
        combiner - the bi-function that receives the original upstream value and the single value emitted by the ObservableSource and returns a result value to be emitted to downstream.
        capacityHint - the number of items expected from the upstream to be buffered while each inner ObservableSource is executing.
        Returns:
        the new ObservableTransformer instance
        Since:
        0.20.4
      • filterAsync

        public static <T> ObservableTransformer<T,​T> filterAsync​(Function<? super T,​? extends ObservableSource<java.lang.Boolean>> asyncPredicate)
        Maps each upstream value into a single true or false value provided by a generated ObservableSource for that input value and emits the input value if the inner ObservableSource returned true.

        Only the first item emitted by the inner ObservableSource's are considered. If the inner ObservableSource is empty, no resulting item is generated for that input value.

        The inner ObservableSources are consumed in order and one at a time.

        Type Parameters:
        T - the input and output value type
        Parameters:
        asyncPredicate - the function that receives the upstream value and returns a ObservableSource that should emit a single true to indicate the original value should pass.
        Returns:
        the new ObservableTransformer instance
        Since:
        0.20.4
      • filterAsync

        public static <T> ObservableTransformer<T,​T> filterAsync​(Function<? super T,​? extends ObservableSource<java.lang.Boolean>> asyncPredicate,
                                                                       int bufferSize)
        Maps each upstream value into a single true or false value provided by a generated ObservableSource for that input value and emits the input value if the inner ObservableSource returned true.

        Only the first item emitted by the inner ObservableSource's are considered. If the inner ObservableSource is empty, no resulting item is generated for that input value.

        The inner ObservableSources are consumed in order and one at a time.

        Type Parameters:
        T - the input and output value type
        Parameters:
        asyncPredicate - the function that receives the upstream value and returns a ObservableSource that should emit a single true to indicate the original value should pass.
        bufferSize - the internal buffer size and prefetch amount to buffer items from upstream until their turn comes up
        Returns:
        the new ObservableTransformer instance
        Since:
        0.20.4