Class FlowableTransformers

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> FlowableTransformer<T,​java.util.List<T>> bufferSplit​(Predicate<? super T> predicate)
      Buffers elements into a List until the given predicate returns true at which point a new empty buffer is started; the particular item will be dropped.
      static <T,​C extends java.util.Collection<? super T>>
      FlowableTransformer<T,​C>
      bufferSplit​(Predicate<? super T> predicate, Supplier<C> bufferSupplier)
      Buffers elements into a custom collection until the given predicate returns true at which point a new empty custom collection is started; the particular item will be dropped.
      static <T> FlowableTransformer<T,​java.util.List<T>> bufferUntil​(Predicate<? super T> predicate)
      Buffers elements into a List until the given predicate returns true at which point a new empty buffer is started.
      static <T,​C extends java.util.Collection<? super T>>
      FlowableTransformer<T,​C>
      bufferUntil​(Predicate<? super T> predicate, Supplier<C> bufferSupplier)
      Buffers elements into a custom collection until the given predicate returns true at which point a new empty custom collection is started.
      static <T> FlowableTransformer<T,​java.util.List<T>> bufferWhile​(Predicate<? super T> predicate)
      Buffers elements into a List while the given predicate returns true; if the predicate returns false for an item, a new buffer is created with the specified item.
      static <T,​C extends java.util.Collection<? super T>>
      FlowableTransformer<T,​C>
      bufferWhile​(Predicate<? super T> predicate, Supplier<C> bufferSupplier)
      Buffers elements into a custom collection while the given predicate returns true; if the predicate returns false for an item, a new collection is created with the specified item.
      static <T> FlowableTransformer<T,​T> cacheLast()
      Cache the very last value of the flow and relay/replay it to Subscribers.
      static <T,​R>
      FlowableTransformer<T,​R>
      coalesce​(Supplier<R> containerSupplier, BiConsumer<R,​T> coalescer)
      Coalesces items from upstream into a container via a consumer and emits the container if there is a downstream demand, otherwise it keeps coalescing into the same container.
      static <T,​R>
      FlowableTransformer<T,​R>
      coalesce​(Supplier<R> containerSupplier, BiConsumer<R,​T> coalescer, int bufferSize)
      Coalesces items from upstream into a container via a consumer and emits the container if there is a downstream demand, otherwise it keeps coalescing into the same container.
      static <T> FlowableTransformer<T,​T> debounceFirst​(long timeout, java.util.concurrent.TimeUnit unit)
      Debounces the upstream by taking an item and dropping subsequent items until the specified amount of time elapses after the last item, after which the process repeats.
      static <T> FlowableTransformer<T,​T> debounceFirst​(long timeout, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
      Debounces the upstream by taking an item and dropping subsequent items until the specified amount of time elapses after the last item, after which the process repeats.
      static <T,​R>
      FlowableTransformer<T,​R>
      errorJump​(FlowableTransformer<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> FlowableTransformer<T,​T> every​(long keep)
      Relays every Nth item from upstream.
      static <T> FlowableTransformer<T,​T> expand​(Function<? super T,​? extends Publisher<? extends T>> expander)
      Emits elements from the source and then expands them into another layer of Publishers, emitting those items recursively until all Publishers become empty in a depth-first manner.
      static <T> FlowableTransformer<T,​T> expand​(Function<? super T,​? extends Publisher<? extends T>> expander, ExpandStrategy strategy)
      Emits elements from the source and then expands them into another layer of Publishers, emitting those items recursively until all Publishers become empty with the specified strategy.
      static <T> FlowableTransformer<T,​T> expand​(Function<? super T,​? extends Publisher<? extends T>> expander, ExpandStrategy strategy, int capacityHint)
      Emits elements from the source and then expands them into another layer of Publishers, emitting those items recursively until all Publishers become empty with the specified strategy.
      static <T> FlowableTransformer<T,​T> expandDelayError​(Function<? super T,​? extends Publisher<? extends T>> expander)
      Emits elements from the source and then expands them into another layer of Publishers, emitting those items recursively until all Publishers become empty in a depth-first manner, delaying errors until all sources terminate.
      static <T> FlowableTransformer<T,​T> expandDelayError​(Function<? super T,​? extends Publisher<? extends T>> expander, ExpandStrategy strategy)
      Emits elements from the source and then expands them into another layer of Publishers, emitting those items recursively until all Publishers become empty with the specified strategy, delaying errors until all sources terminate.
      static <T> FlowableTransformer<T,​T> expandDelayError​(Function<? super T,​? extends Publisher<? extends T>> expander, ExpandStrategy strategy, int capacityHint)
      Emits elements from the source and then expands them into another layer of Publishers, emitting those items recursively until all Publishers become empty with the specified strategy, delaying errors until all sources terminate.
      static <T> FlowableTransformer<T,​T> filterAsync​(Function<? super T,​? extends Publisher<java.lang.Boolean>> asyncPredicate)
      Maps each upstream value into a single true or false value provided by a generated Publisher for that input value and emits the input value if the inner Publisher returned true.
      static <T> FlowableTransformer<T,​T> filterAsync​(Function<? super T,​? extends Publisher<java.lang.Boolean>> asyncPredicate, int bufferSize)
      Maps each upstream value into a single true or false value provided by a generated Publisher for that input value and emits the input value if the inner Publisher returned true.
      static <T,​R>
      FlowableTransformer<T,​R>
      flatMapAsync​(Function<? super T,​? extends Publisher<? extends R>> mapper, Scheduler scheduler)
      Maps the upstream values into Publisher and merges at most 32 of them at once, collects and emits the items on the specified scheduler.
      static <T,​R>
      FlowableTransformer<T,​R>
      flatMapAsync​(Function<? super T,​? extends Publisher<? extends R>> mapper, Scheduler scheduler, boolean depthFirst)
      Maps the upstream values into Publisher and merges at most 32 of them at once, collects and emits the items on the specified scheduler.
      static <T,​R>
      FlowableTransformer<T,​R>
      flatMapAsync​(Function<? super T,​? extends Publisher<? extends R>> mapper, Scheduler scheduler, int maxConcurrency, int bufferSize, boolean depthFirst)
      Maps the upstream values into Publisher and merges at most 32 of them at once, collects and emits the items on the specified scheduler.
      static <T,​R>
      FlowableTransformer<T,​R>
      flatMapSync​(Function<? super T,​? extends Publisher<? extends R>> mapper)
      Maps the upstream values into Publisher and merges at most 32 of them at once, optimized for mainly synchronous sources.
      static <T,​R>
      FlowableTransformer<T,​R>
      flatMapSync​(Function<? super T,​? extends Publisher<? extends R>> mapper, boolean depthFirst)
      Maps the upstream values into Publisher and merges at most maxConcurrency of them at once, optimized for mainly synchronous sources.
      static <T,​R>
      FlowableTransformer<T,​R>
      flatMapSync​(Function<? super T,​? extends Publisher<? extends R>> mapper, int maxConcurrency, int bufferSize, boolean depthFirst)
      Maps the upstream values into Publisher and merges at most maxConcurrency of them at once, optimized for mainly synchronous sources.
      static <T> FlowableTransformer<T,​java.lang.Long> indexOf​(Predicate<? super T> predicate)
      Returns the first index of an element that matches a predicate or -1L if no elements match.
      static <T,​R>
      FlowableTransformer<T,​R>
      mapAsync​(Function<? super T,​? extends Publisher<? extends R>> mapper)
      Maps each upstream value into a single value provided by a generated Publisher for that input value to be emitted to downstream.
      static <T,​R>
      FlowableTransformer<T,​R>
      mapAsync​(Function<? super T,​? extends Publisher<? extends R>> mapper, int bufferSize)
      Maps each upstream value into a single value provided by a generated Publisher for that input value to be emitted to downstream.
      static <T,​U,​R>
      FlowableTransformer<T,​R>
      mapAsync​(Function<? super T,​? extends Publisher<? extends U>> mapper, BiFunction<? super T,​? super U,​? extends R> combiner)
      Maps each upstream value into a single value provided by a generated Publisher 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>
      FlowableTransformer<T,​R>
      mapAsync​(Function<? super T,​? extends Publisher<? extends U>> mapper, BiFunction<? super T,​? super U,​? extends R> combiner, int bufferSize)
      Maps each upstream value into a single value provided by a generated Publisher for that input value and combines the original and generated single value into a final result item to be emitted to downstream.
      static <T,​R>
      FlowableTransformer<T,​R>
      mapFilter​(BiConsumer<? super T,​? super BasicEmitter<R>> consumer)
      Allows mapping or filtering an upstream value through an emitter.
      static <T> FlowableTransformer<T,​T> onBackpressureTimeout​(int maxSize, long timeout, java.util.concurrent.TimeUnit unit, Scheduler scheduler, Consumer<? super T> onEvict)
      Buffers the incoming values from upstream up to a maximum size or timeout if the downstream can't keep up.
      static <T> FlowableTransformer<T,​T> onBackpressureTimeout​(long timeout, java.util.concurrent.TimeUnit unit)
      Buffers the incoming values from upstream up to a maximum timeout if the downstream can't keep up.
      static <T> FlowableTransformer<T,​T> onBackpressureTimeout​(long timeout, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
      Buffers the incoming values from upstream up to a maximum timeout if the downstream can't keep up, running on a custom scheduler.
      static <T> FlowableTransformer<T,​T> onBackpressureTimeout​(long timeout, java.util.concurrent.TimeUnit unit, Scheduler scheduler, Consumer<? super T> onEvict)
      Buffers the incoming values from upstream up to a maximum size or timeout if the downstream can't keep up.
      static <T,​I,​A,​R>
      FlowableTransformer<T,​R>
      partialCollect​(Consumer<? super PartialCollectEmitter<T,​I,​A,​R>> handler, Consumer<? super T> cleaner, int prefetch)
      Allows converting upstream items into output objects where an upstream item may represent such output objects partially or may represent more than one output object.
      static <T> FlowableTransformer<T,​T> requestObserveOn​(Scheduler scheduler)
      Requests items one-by-one from the upstream from the given Scheduler and emits those items received on the same Scheduler, allowing a more interleaved usage of the target Scheduler (aka "fair" use).
      static <T> FlowableTransformer<T,​T> requestSample​(long initialDelay, long period, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
      Issues a request(1) to the upstream after an initial delay, then repeatedly by given period.
      static <T> FlowableTransformer<T,​T> requestSample​(long period, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
      Issues a request(1) to the upstream repeatedly after the given period time elapses (including the very first request(1)).
      static <T,​U>
      FlowableTransformer<T,​T>
      requestSample​(Publisher<U> other)
      Issues a request(1) to the upstream when the other Publisher signals an onNext.
      static <T> FlowableTransformer<T,​T> spanout​(long initialDelay, long betweenDelay, java.util.concurrent.TimeUnit unit)
      Inserts a time delay between emissions from the upstream source, including an initial delay.
      static <T> FlowableTransformer<T,​T> spanout​(long initialDelay, long betweenDelay, java.util.concurrent.TimeUnit unit, boolean delayError)
      Inserts a time delay between emissions from the upstream source, including an initial delay.
      static <T> FlowableTransformer<T,​T> spanout​(long initialDelay, long betweenDelay, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
      Inserts a time delay between emissions from the upstream source, including an initial delay.
      static <T> FlowableTransformer<T,​T> spanout​(long initialDelay, long betweenDelay, java.util.concurrent.TimeUnit unit, Scheduler scheduler, boolean delayError)
      Inserts a time delay between emissions from the upstream source, including an initial delay.
      static <T> FlowableTransformer<T,​T> spanout​(long betweenDelay, java.util.concurrent.TimeUnit unit)
      Inserts a time delay between emissions from the upstream source.
      static <T> FlowableTransformer<T,​T> spanout​(long betweenDelay, java.util.concurrent.TimeUnit unit, boolean delayError)
      Inserts a time delay between emissions from the upstream source, including an initial delay.
      static <T> FlowableTransformer<T,​T> spanout​(long betweenDelay, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
      Inserts a time delay between emissions from the upstream source.
      static <T> FlowableTransformer<T,​T> spanout​(long betweenDelay, java.util.concurrent.TimeUnit unit, Scheduler scheduler, boolean delayError)
      Inserts a time delay between emissions from the upstream source, including an initial delay.
      static <T,​R>
      FlowableTransformer<T,​R>
      switchFlatMap​(Function<? super T,​? extends Publisher<? extends R>> mapper, int maxActive)
      Combination of switchMap and flatMap where there is a limit on the number of concurrent sources to be flattened into a single sequence and if the operator is at the given maximum active count, a newer source Publisher will switch out the oldest active source Publisher being merged.
      static <T,​R>
      FlowableTransformer<T,​R>
      switchFlatMap​(Function<? super T,​? extends Publisher<? extends R>> mapper, int maxActive, int bufferSize)
      Combination of switchMap and flatMap where there is a limit on the number of concurrent sources to be flattened into a single sequence and if the operator is at the given maximum active count, a newer source Publisher will switch out the oldest active source Publisher being merged.
      static <T> FlowableTransformer<T,​T> switchIfEmpty​(java.lang.Iterable<? extends Publisher<? extends T>> alternatives)
      If the upstream turns out to be empty, it keeps switching to the alternative sources until one of them is non-empty or there are no more alternatives remaining.
      static <T> FlowableTransformer<T,​T> switchIfEmptyArray​(Publisher<? extends T>... alternatives)
      If the upstream turns out to be empty, it keeps switching to the alternative sources until one of them is non-empty or there are no more alternatives remaining.
      static <T> FlowableTransformer<T,​T> switchOnFirst​(Predicate<? super T> predicate, Function<? super T,​? extends Publisher<? extends T>> selector)
      Switches to an alternate flow if the very first item of the main flow matches the given predicate.
      static <T> FlowableTransformer<T,​T> timeoutLast​(long timeout, java.util.concurrent.TimeUnit unit)
      Emit the last item when the upstream completes or the the latest received if the specified timeout elapses since the last received item.
      static <T> FlowableTransformer<T,​T> timeoutLast​(long timeout, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
      Emit the last item when the upstream completes or the the latest received if the specified timeout elapses since the last received item.
      static <T> FlowableTransformer<T,​T> timeoutLastAbsolute​(long timeout, java.util.concurrent.TimeUnit unit)
      Emit the last item when the upstream completes or the the latest received if the specified timeout elapses since the start of the sequence.
      static <T> FlowableTransformer<T,​T> timeoutLastAbsolute​(long timeout, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
      Emit the last item when the upstream completes or the the latest received if the specified timeout elapses since the start of the sequence.
      static <T> FlowableTransformer<T,​T> valve​(Publisher<java.lang.Boolean> other)
      Relays values until the other Publisher signals false and resumes if the other Publisher signals true again, like closing and opening a valve and not losing any items from the main source.
      static <T> FlowableTransformer<T,​T> valve​(Publisher<java.lang.Boolean> other, boolean defaultOpen)
      Relays values until the other Publisher signals false and resumes if the other Publisher 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> FlowableTransformer<T,​T> valve​(Publisher<java.lang.Boolean> other, boolean defaultOpen, int bufferSize)
      Relays values until the other Publisher signals false and resumes if the other Publisher 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.
      static <T> FlowableTransformer<T,​Flowable<T>> windowSplit​(Predicate<? super T> predicate)
      Emits elements into a Flowable window until the given predicate returns true at which point a new Flowable window is emitted; the particular item will be dropped.
      static <T> FlowableTransformer<T,​Flowable<T>> windowSplit​(Predicate<? super T> predicate, int bufferSize)
      Emits elements into a Flowable window until the given predicate returns true at which point a new Flowable window is emitted; the particular item will be dropped.
      static <T> FlowableTransformer<T,​Flowable<T>> windowUntil​(Predicate<? super T> predicate)
      Emits elements into a Flowable window until the given predicate returns true at which point a new Flowable window is emitted.
      static <T> FlowableTransformer<T,​Flowable<T>> windowUntil​(Predicate<? super T> predicate, int bufferSize)
      Emits elements into a Flowable window until the given predicate returns true at which point a new Flowable window is emitted.
      static <T> FlowableTransformer<T,​Flowable<T>> windowWhile​(Predicate<? super T> predicate)
      Emits elements into a Flowable window while the given predicate returns true.
      static <T> FlowableTransformer<T,​Flowable<T>> windowWhile​(Predicate<? super T> predicate, int bufferSize)
      Emits elements into a Flowable window while the given predicate returns true.
      • Methods inherited from class java.lang.Object

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

      • valve

        @SchedulerSupport("none")
        @BackpressureSupport(PASS_THROUGH)
        public static <T> FlowableTransformer<T,​T> valve​(Publisher<java.lang.Boolean> other)
        Relays values until the other Publisher signals false and resumes if the other Publisher 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 Publisher completes, the sequence terminates with an IllegalStateException.
        • The operator doesn't run on any particular Scheduler.
        • The operator is a pass-through for backpressure and 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 FlowableTransformer instance
        Throws:
        java.lang.NullPointerException - if other is null
        Since:
        0.7.2
      • valve

        @SchedulerSupport("none")
        @BackpressureSupport(PASS_THROUGH)
        public static <T> FlowableTransformer<T,​T> valve​(Publisher<java.lang.Boolean> other,
                                                               boolean defaultOpen)
        Relays values until the other Publisher signals false and resumes if the other Publisher 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 Publisher completes, the sequence terminates with an IllegalStateException.
        • The operator doesn't run on any particular Scheduler.
        • The operator is a pass-through for backpressure and 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 FlowableTransformer instance
        Throws:
        java.lang.NullPointerException - if other is null
        Since:
        0.7.2
      • valve

        @SchedulerSupport("none")
        @BackpressureSupport(PASS_THROUGH)
        public static <T> FlowableTransformer<T,​T> valve​(Publisher<java.lang.Boolean> other,
                                                               boolean defaultOpen,
                                                               int bufferSize)
        Relays values until the other Publisher signals false and resumes if the other Publisher 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 Publisher 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 FlowableTransformer instance
        Throws:
        java.lang.IllegalArgumentException - if bufferSize <= 0
        java.lang.NullPointerException - if other is null
        Since:
        0.7.2
      • bufferWhile

        @SchedulerSupport("none")
        @BackpressureSupport(FULL)
        public static <T> FlowableTransformer<T,​java.util.List<T>> bufferWhile​(Predicate<? super T> predicate)
        Buffers elements into a List while the given predicate returns true; if the predicate returns false for an item, a new buffer is created with the specified item.
        Type Parameters:
        T - the source value type
        Parameters:
        predicate - the predicate receiving the current value and if returns false, a new buffer is created with the specified item
        Returns:
        the new FlowableTransformer instance
        Since:
        0.8.0
      • bufferWhile

        @SchedulerSupport("none")
        @BackpressureSupport(FULL)
        public static <T,​C extends java.util.Collection<? super T>> FlowableTransformer<T,​C> bufferWhile​(Predicate<? super T> predicate,
                                                                                                                     Supplier<C> bufferSupplier)
        Buffers elements into a custom collection while the given predicate returns true; if the predicate returns false for an item, a new collection is created with the specified item.
        Type Parameters:
        T - the source value type
        C - the collection type
        Parameters:
        predicate - the predicate receiving the current value and if returns false, a new collection is created with the specified item
        bufferSupplier - the supplier that returns a fresh collection
        Returns:
        the new FlowableTransformer instance
        Since:
        0.8.0
      • bufferUntil

        @SchedulerSupport("none")
        @BackpressureSupport(FULL)
        public static <T> FlowableTransformer<T,​java.util.List<T>> bufferUntil​(Predicate<? super T> predicate)
        Buffers elements into a List until the given predicate returns true at which point a new empty buffer is started.
        Type Parameters:
        T - the source value type
        Parameters:
        predicate - the predicate receiving the current item and if returns true, the current buffer is emitted and a fresh empty buffer is created
        Returns:
        the new FlowableTransformer instance
        Since:
        0.8.0
      • bufferUntil

        @SchedulerSupport("none")
        @BackpressureSupport(FULL)
        public static <T,​C extends java.util.Collection<? super T>> FlowableTransformer<T,​C> bufferUntil​(Predicate<? super T> predicate,
                                                                                                                     Supplier<C> bufferSupplier)
        Buffers elements into a custom collection until the given predicate returns true at which point a new empty custom collection is started.
        Type Parameters:
        T - the source value type
        C - the collection type
        Parameters:
        predicate - the predicate receiving the current item and if returns true, the current collection is emitted and a fresh empty collection is created
        bufferSupplier - the supplier that returns a fresh collection
        Returns:
        the new Flowable instance
        Since:
        0.8.0
      • bufferSplit

        @SchedulerSupport("none")
        @BackpressureSupport(FULL)
        public static <T> FlowableTransformer<T,​java.util.List<T>> bufferSplit​(Predicate<? super T> predicate)
        Buffers elements into a List until the given predicate returns true at which point a new empty buffer is started; the particular item will be dropped.
        Type Parameters:
        T - the source value type
        Parameters:
        predicate - the predicate receiving the current item and if returns true, the current buffer is emitted and a fresh empty buffer is created
        Returns:
        the new FlowableTransformer instance
        Since:
        0.14.3
      • bufferSplit

        @SchedulerSupport("none")
        @BackpressureSupport(FULL)
        public static <T,​C extends java.util.Collection<? super T>> FlowableTransformer<T,​C> bufferSplit​(Predicate<? super T> predicate,
                                                                                                                     Supplier<C> bufferSupplier)
        Buffers elements into a custom collection until the given predicate returns true at which point a new empty custom collection is started; the particular item will be dropped.
        Type Parameters:
        T - the source value type
        C - the collection type
        Parameters:
        predicate - the predicate receiving the current item and if returns true, the current collection is emitted and a fresh empty collection is created
        bufferSupplier - the Supplier that returns a fresh collection
        Returns:
        the new Flowable instance
        Since:
        0.14.3
      • spanout

        @BackpressureSupport(PASS_THROUGH)
        @SchedulerSupport("io.reactivex:computation")
        public static <T> FlowableTransformer<T,​T> spanout​(long betweenDelay,
                                                                 java.util.concurrent.TimeUnit unit)
        Inserts a time delay between emissions from the upstream source.
        Backpressure:
        The operator itself doesn't interfere with backpressure and uses an unbounded internal buffer to store elements that need delay.
        Scheduler:
        The operator uses the computation Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        betweenDelay - the (minimum) delay time between elements
        unit - the time unit of the initial delay and the between delay values
        Returns:
        the new FlowableTransformer instance
        Since:
        0.9.0
      • spanout

        @BackpressureSupport(PASS_THROUGH)
        @SchedulerSupport("custom")
        public static <T> FlowableTransformer<T,​T> spanout​(long betweenDelay,
                                                                 java.util.concurrent.TimeUnit unit,
                                                                 Scheduler scheduler)
        Inserts a time delay between emissions from the upstream source.
        Backpressure:
        The operator itself doesn't interfere with backpressure and uses an unbounded internal buffer to store elements that need delay.
        Scheduler:
        The operator uses a custom Scheduler you provide.
        Type Parameters:
        T - the value type
        Parameters:
        betweenDelay - the (minimum) delay time between elements
        unit - the time unit of the initial delay and the between delay values
        scheduler - the scheduler to delay and emit the values on
        Returns:
        the new FlowableTransformer instance
        Since:
        0.9.0
      • spanout

        @BackpressureSupport(PASS_THROUGH)
        @SchedulerSupport("io.reactivex:computation")
        public static <T> FlowableTransformer<T,​T> spanout​(long initialDelay,
                                                                 long betweenDelay,
                                                                 java.util.concurrent.TimeUnit unit)
        Inserts a time delay between emissions from the upstream source, including an initial delay.
        Backpressure:
        The operator itself doesn't interfere with backpressure and uses an unbounded internal buffer to store elements that need delay.
        Scheduler:
        The operator uses the computation Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        initialDelay - the initial delay
        betweenDelay - the (minimum) delay time between elements
        unit - the time unit of the initial delay and the between delay values
        Returns:
        the new FlowableTransformer instance
        Since:
        0.9.0
      • spanout

        @BackpressureSupport(PASS_THROUGH)
        @SchedulerSupport("custom")
        public static <T> FlowableTransformer<T,​T> spanout​(long initialDelay,
                                                                 long betweenDelay,
                                                                 java.util.concurrent.TimeUnit unit,
                                                                 Scheduler scheduler)
        Inserts a time delay between emissions from the upstream source, including an initial delay.
        Backpressure:
        The operator itself doesn't interfere with backpressure and uses an unbounded internal buffer to store elements that need delay.
        Scheduler:
        The operator uses a custom Scheduler you provide.
        Type Parameters:
        T - the value type
        Parameters:
        initialDelay - the initial delay
        betweenDelay - the (minimum) delay time between elements
        unit - the time unit of the initial delay and the between delay values
        scheduler - the scheduler to delay and emit the values on
        Returns:
        the new FlowableTransformer instance
        Since:
        0.9.0
      • spanout

        @BackpressureSupport(PASS_THROUGH)
        @SchedulerSupport("io.reactivex:computation")
        public static <T> FlowableTransformer<T,​T> spanout​(long betweenDelay,
                                                                 java.util.concurrent.TimeUnit unit,
                                                                 boolean delayError)
        Inserts a time delay between emissions from the upstream source, including an initial delay.
        Backpressure:
        The operator itself doesn't interfere with backpressure and uses an unbounded internal buffer to store elements that need delay.
        Scheduler:
        The operator uses the computation Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        betweenDelay - the (minimum) delay time between elements
        unit - the time unit of the initial delay and the between delay values
        delayError - delay the onError event from upstream
        Returns:
        the new FlowableTransformer instance
        Since:
        0.9.0
      • spanout

        @BackpressureSupport(PASS_THROUGH)
        @SchedulerSupport("custom")
        public static <T> FlowableTransformer<T,​T> spanout​(long betweenDelay,
                                                                 java.util.concurrent.TimeUnit unit,
                                                                 Scheduler scheduler,
                                                                 boolean delayError)
        Inserts a time delay between emissions from the upstream source, including an initial delay.
        Backpressure:
        The operator itself doesn't interfere with backpressure and uses an unbounded internal buffer to store elements that need delay.
        Scheduler:
        The operator uses a custom Scheduler you provide.
        Type Parameters:
        T - the value type
        Parameters:
        betweenDelay - the (minimum) delay time between elements
        unit - the time unit of the initial delay and the between delay values
        scheduler - the scheduler to delay and emit the values on
        delayError - delay the onError event from upstream
        Returns:
        the new FlowableTransformer instance
        Since:
        0.9.0
      • spanout

        @BackpressureSupport(PASS_THROUGH)
        @SchedulerSupport("io.reactivex:computation")
        public static <T> FlowableTransformer<T,​T> spanout​(long initialDelay,
                                                                 long betweenDelay,
                                                                 java.util.concurrent.TimeUnit unit,
                                                                 boolean delayError)
        Inserts a time delay between emissions from the upstream source, including an initial delay.
        Backpressure:
        The operator itself doesn't interfere with backpressure and uses an unbounded internal buffer to store elements that need delay.
        Scheduler:
        The operator uses the computation Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        initialDelay - the initial delay
        betweenDelay - the (minimum) delay time between elements
        unit - the time unit of the initial delay and the between delay values
        delayError - delay the onError event from upstream
        Returns:
        the new FlowableTransformer instance
        Since:
        0.9.0
      • spanout

        @BackpressureSupport(PASS_THROUGH)
        @SchedulerSupport("custom")
        public static <T> FlowableTransformer<T,​T> spanout​(long initialDelay,
                                                                 long betweenDelay,
                                                                 java.util.concurrent.TimeUnit unit,
                                                                 Scheduler scheduler,
                                                                 boolean delayError)
        Inserts a time delay between emissions from the upstream source, including an initial delay.
        Backpressure:
        The operator itself doesn't interfere with backpressure and uses an unbounded internal buffer to store elements that need delay.
        Scheduler:
        The operator uses a custom Scheduler you provide.
        Type Parameters:
        T - the value type
        Parameters:
        initialDelay - the initial delay
        betweenDelay - the (minimum) delay time between elements
        unit - the time unit of the initial delay and the between delay values
        scheduler - the scheduler to delay and emit the values on
        delayError - delay the onError event from upstream
        Returns:
        the new FlowableTransformer instance
        Since:
        0.9.0
      • mapFilter

        @BackpressureSupport(PASS_THROUGH)
        @SchedulerSupport("none")
        public static <T,​R> FlowableTransformer<T,​R> mapFilter​(BiConsumer<? super T,​? super BasicEmitter<R>> consumer)
        Allows mapping or filtering an upstream value through an emitter.
        Type Parameters:
        T - the input value type
        R - the output value type
        Parameters:
        consumer - the consumer that is called for each upstream value and should call one of the doXXX methods on the BasicEmitter it receives (individual to each Subscriber).
        Returns:
        the new FlowableTransformer instance
        Since:
        0.10.0
      • onBackpressureTimeout

        @BackpressureSupport(UNBOUNDED_IN)
        @SchedulerSupport("io.reactivex:computation")
        public static <T> FlowableTransformer<T,​T> onBackpressureTimeout​(long timeout,
                                                                               java.util.concurrent.TimeUnit unit)
        Buffers the incoming values from upstream up to a maximum timeout if the downstream can't keep up.
        Type Parameters:
        T - the value type
        Parameters:
        timeout - the maximum age of an element in the buffer
        unit - the time unit of the timeout
        Returns:
        the new FlowableTransformer instance
        Since:
        0.13.0
        See Also:
        for more options
      • onBackpressureTimeout

        @BackpressureSupport(UNBOUNDED_IN)
        @SchedulerSupport("custom")
        public static <T> FlowableTransformer<T,​T> onBackpressureTimeout​(long timeout,
                                                                               java.util.concurrent.TimeUnit unit,
                                                                               Scheduler scheduler,
                                                                               Consumer<? super T> onEvict)
        Buffers the incoming values from upstream up to a maximum size or timeout if the downstream can't keep up.
        Type Parameters:
        T - the value type
        Parameters:
        timeout - the maximum age of an element in the buffer
        unit - the time unit of the timeout
        scheduler - the scheduler to be used as time source and to trigger the timeout & eviction
        onEvict - called when an element is evicted, maybe concurrently
        Returns:
        the new FlowableTransformer instance
        Since:
        0.13.0
      • onBackpressureTimeout

        @BackpressureSupport(UNBOUNDED_IN)
        @SchedulerSupport("custom")
        public static <T> FlowableTransformer<T,​T> onBackpressureTimeout​(long timeout,
                                                                               java.util.concurrent.TimeUnit unit,
                                                                               Scheduler scheduler)
        Buffers the incoming values from upstream up to a maximum timeout if the downstream can't keep up, running on a custom scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        timeout - the maximum age of an element in the buffer
        unit - the time unit of the timeout
        scheduler - the scheduler to be used as time source and to trigger the timeout & eviction
        Returns:
        the new FlowableTransformer instance
        Since:
        0.13.0
        See Also:
        for more options
      • onBackpressureTimeout

        @BackpressureSupport(UNBOUNDED_IN)
        @SchedulerSupport("custom")
        public static <T> FlowableTransformer<T,​T> onBackpressureTimeout​(int maxSize,
                                                                               long timeout,
                                                                               java.util.concurrent.TimeUnit unit,
                                                                               Scheduler scheduler,
                                                                               Consumer<? super T> onEvict)
        Buffers the incoming values from upstream up to a maximum size or timeout if the downstream can't keep up.
        Type Parameters:
        T - the value type
        Parameters:
        maxSize - the maximum number of elements in the buffer, beyond that, the oldest element is evicted
        timeout - the maximum age of an element in the buffer
        unit - the time unit of the timeout
        scheduler - the scheduler to be used as time source and to trigger the timeout & eviction
        onEvict - called when an element is evicted, maybe concurrently
        Returns:
        the new FlowableTransformer instance
        Since:
        0.13.0
      • every

        @BackpressureSupport(SPECIAL)
        @SchedulerSupport("none")
        public static <T> FlowableTransformer<T,​T> every​(long keep)
        Relays every Nth item from upstream.
        Backpressure:
        The operator requests keep times what the downstream requests and skips @code keep-1} items.
        Scheduler:
        The operator doesn't run on any particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        keep - the period of items to keep, i.e., this minus one items will be dropped before emitting an item directly
        Returns:
        the new FlowableTransformer instance
        Since:
        0.14.2
      • cacheLast

        @BackpressureSupport(UNBOUNDED_IN)
        @SchedulerSupport("none")
        public static <T> FlowableTransformer<T,​T> cacheLast()
        Cache the very last value of the flow and relay/replay it to Subscribers.

        The operator subscribes to the upstream when the first downstream Subscriber arrives. Once connected, the upstream can't be stopped from the downstream even if all Subscribers cancel.

        A difference from replay(1) is that replay() is likely holding onto 2 references due to continuity requirements whereas this operator is guaranteed to hold only the very last item.

        Type Parameters:
        T - the value type emitted
        Returns:
        the new FlowableTransformer instance
        Since:
        0.15.0
      • timeoutLast

        @BackpressureSupport(UNBOUNDED_IN)
        @SchedulerSupport("io.reactivex:computation")
        public static <T> FlowableTransformer<T,​T> timeoutLast​(long timeout,
                                                                     java.util.concurrent.TimeUnit unit)
        Emit the last item when the upstream completes or the the latest received if the specified timeout elapses since the last received item.
        Type Parameters:
        T - the value type
        Parameters:
        timeout - the timeout value
        unit - the timeout time unit
        Returns:
        the new Flowable type
        Since:
        0.15.0
      • timeoutLast

        @BackpressureSupport(UNBOUNDED_IN)
        @SchedulerSupport("custom")
        public static <T> FlowableTransformer<T,​T> timeoutLast​(long timeout,
                                                                     java.util.concurrent.TimeUnit unit,
                                                                     Scheduler scheduler)
        Emit the last item when the upstream completes or the the latest received if the specified timeout elapses since the last received item.
        Type Parameters:
        T - the value type
        Parameters:
        timeout - the timeout value
        unit - the timeout time unit
        scheduler - the scheduler to run the timeout and possible emit the last/latest
        Returns:
        the new Flowable type
        Since:
        0.15.0
      • timeoutLastAbsolute

        @BackpressureSupport(UNBOUNDED_IN)
        @SchedulerSupport("io.reactivex:computation")
        public static <T> FlowableTransformer<T,​T> timeoutLastAbsolute​(long timeout,
                                                                             java.util.concurrent.TimeUnit unit)
        Emit the last item when the upstream completes or the the latest received if the specified timeout elapses since the start of the sequence.
        Type Parameters:
        T - the value type
        Parameters:
        timeout - the timeout value
        unit - the timeout time unit
        Returns:
        the new Flowable type
        Since:
        0.15.0
      • timeoutLastAbsolute

        @BackpressureSupport(UNBOUNDED_IN)
        @SchedulerSupport("custom")
        public static <T> FlowableTransformer<T,​T> timeoutLastAbsolute​(long timeout,
                                                                             java.util.concurrent.TimeUnit unit,
                                                                             Scheduler scheduler)
        Emit the last item when the upstream completes or the the latest received if the specified timeout elapses since the start of the sequence.
        Type Parameters:
        T - the value type
        Parameters:
        timeout - the timeout value
        unit - the timeout time unit
        scheduler - the scheduler to run the timeout and possible emit the last/latest
        Returns:
        the new Flowable type
        Since:
        0.15.0
      • debounceFirst

        @BackpressureSupport(PASS_THROUGH)
        @SchedulerSupport("io.reactivex:computation")
        public static <T> FlowableTransformer<T,​T> debounceFirst​(long timeout,
                                                                       java.util.concurrent.TimeUnit unit)
        Debounces the upstream by taking an item and dropping subsequent items until the specified amount of time elapses after the last item, after which the process repeats.

        Note that the operator uses the computation Scheduler for the source of time but doesn't use it to emit non-dropped items or terminal events. The operator uses calculation with the current time to decide if an upstream item may pass or not.

        Type Parameters:
        T - the value type
        Parameters:
        timeout - the timeout
        unit - the unit of measure of the timeout parameter
        Returns:
        the new FlowableTransformer instance
        Since:
        0.15.0
      • debounceFirst

        @BackpressureSupport(PASS_THROUGH)
        @SchedulerSupport("custom")
        public static <T> FlowableTransformer<T,​T> debounceFirst​(long timeout,
                                                                       java.util.concurrent.TimeUnit unit,
                                                                       Scheduler scheduler)
        Debounces the upstream by taking an item and dropping subsequent items until the specified amount of time elapses after the last item, after which the process repeats.

        Note that the operator uses the computation Scheduler for the source of time but doesn't use it to emit non-dropped items or terminal events. The operator uses calculation with the current time to decide if an upstream item may pass or not.

        Type Parameters:
        T - the value type
        Parameters:
        timeout - the timeout
        unit - the unit of measure of the timeout parameter
        scheduler - the scheduler used for getting the current time when evaluating upstream items
        Returns:
        the new FlowableTransformer instance
        Since:
        0.15.0
      • switchFlatMap

        @BackpressureSupport(FULL)
        @SchedulerSupport("none")
        public static <T,​R> FlowableTransformer<T,​R> switchFlatMap​(Function<? super T,​? extends Publisher<? extends R>> mapper,
                                                                               int maxActive)
        Combination of switchMap and flatMap where there is a limit on the number of concurrent sources to be flattened into a single sequence and if the operator is at the given maximum active count, a newer source Publisher will switch out the oldest active source Publisher being merged.
        Type Parameters:
        T - the source value type
        R - the result value type
        Parameters:
        mapper - the function that maps an upstream value into a Publisher to be merged/switched
        maxActive - the maximum number of active inner Publishers
        Returns:
        the new FlowableTransformer instance
        Since:
        0.15.0
      • switchFlatMap

        @BackpressureSupport(FULL)
        @SchedulerSupport("none")
        public static <T,​R> FlowableTransformer<T,​R> switchFlatMap​(Function<? super T,​? extends Publisher<? extends R>> mapper,
                                                                               int maxActive,
                                                                               int bufferSize)
        Combination of switchMap and flatMap where there is a limit on the number of concurrent sources to be flattened into a single sequence and if the operator is at the given maximum active count, a newer source Publisher will switch out the oldest active source Publisher being merged.
        Type Parameters:
        T - the source value type
        R - the result value type
        Parameters:
        mapper - the function that maps an upstream value into a Publisher to be merged/switched
        maxActive - the maximum number of active inner Publishers
        bufferSize - the number of items to prefetch from each inner source
        Returns:
        the new FlowableTransformer instance
        Since:
        0.15.0
      • flatMapSync

        public static <T,​R> FlowableTransformer<T,​R> flatMapSync​(Function<? super T,​? extends Publisher<? extends R>> mapper)
        Maps the upstream values into Publisher and merges at most 32 of them at once, optimized for mainly synchronous sources.
        Type Parameters:
        T - the input value type
        R - the result value type
        Parameters:
        mapper - the function mapping from a value into a Publisher
        Returns:
        the new FlowableTransformer instance
        Since:
        0.16.0
      • flatMapSync

        public static <T,​R> FlowableTransformer<T,​R> flatMapSync​(Function<? super T,​? extends Publisher<? extends R>> mapper,
                                                                             boolean depthFirst)
        Maps the upstream values into Publisher and merges at most maxConcurrency of them at once, optimized for mainly synchronous sources.
        Type Parameters:
        T - the input value type
        R - the result value type
        Parameters:
        mapper - the function mapping from a value into a Publisher
        depthFirst - if true, the inner sources are drained as much as possible if false, the inner sources are consumed in a round-robin fashion
        Returns:
        the new FlowableTransformer instance
        Since:
        0.16.0
      • flatMapSync

        public static <T,​R> FlowableTransformer<T,​R> flatMapSync​(Function<? super T,​? extends Publisher<? extends R>> mapper,
                                                                             int maxConcurrency,
                                                                             int bufferSize,
                                                                             boolean depthFirst)
        Maps the upstream values into Publisher and merges at most maxConcurrency of them at once, optimized for mainly synchronous sources.
        Type Parameters:
        T - the input value type
        R - the result value type
        Parameters:
        mapper - the function mapping from a value into a Publisher
        maxConcurrency - the maximum number of sources merged at once
        bufferSize - the prefetch on each inner source
        depthFirst - if true, the inner sources are drained as much as possible if false, the inner sources are consumed in a round-robin fashion
        Returns:
        the new FlowableTransformer instance
        Since:
        0.16.0
      • flatMapAsync

        public static <T,​R> FlowableTransformer<T,​R> flatMapAsync​(Function<? super T,​? extends Publisher<? extends R>> mapper,
                                                                              Scheduler scheduler)
        Maps the upstream values into Publisher and merges at most 32 of them at once, collects and emits the items on the specified scheduler.

        This operator can be considered as a fusion between a flatMapSync and observeOn.

        Type Parameters:
        T - the input value type
        R - the output value type
        Parameters:
        mapper - the function mapping from a value into a Publisher
        scheduler - the Scheduler to use to collect and emit merged items
        Returns:
        the new FlowableTransformer instance
        Since:
        0.16.0
      • flatMapAsync

        public static <T,​R> FlowableTransformer<T,​R> flatMapAsync​(Function<? super T,​? extends Publisher<? extends R>> mapper,
                                                                              Scheduler scheduler,
                                                                              boolean depthFirst)
        Maps the upstream values into Publisher and merges at most 32 of them at once, collects and emits the items on the specified scheduler.

        This operator can be considered as a fusion between a flatMapSync and observeOn.

        Type Parameters:
        T - the input value type
        R - the output value type
        Parameters:
        mapper - the function mapping from a value into a Publisher
        scheduler - the Scheduler to use to collect and emit merged items
        depthFirst - if true, the inner sources are drained as much as possible if false, the inner sources are consumed in a round-robin fashion
        Returns:
        the new FlowableTransformer instance
        Since:
        0.16.0
      • flatMapAsync

        public static <T,​R> FlowableTransformer<T,​R> flatMapAsync​(Function<? super T,​? extends Publisher<? extends R>> mapper,
                                                                              Scheduler scheduler,
                                                                              int maxConcurrency,
                                                                              int bufferSize,
                                                                              boolean depthFirst)
        Maps the upstream values into Publisher and merges at most 32 of them at once, collects and emits the items on the specified scheduler.

        This operator can be considered as a fusion between a flatMapSync and observeOn.

        Type Parameters:
        T - the input value type
        R - the output value type
        Parameters:
        mapper - the function mapping from a value into a Publisher
        scheduler - the Scheduler to use to collect and emit merged items
        maxConcurrency - the maximum number of sources merged at once
        bufferSize - the prefetch on each inner source
        depthFirst - if true, the inner sources are drained as much as possible if false, the inner sources are consumed in a round-robin fashion
        Returns:
        the new FlowableTransformer instance
        Since:
        0.16.0
      • switchIfEmptyArray

        @SafeVarargs
        public static <T> FlowableTransformer<T,​T> switchIfEmptyArray​(Publisher<? extends T>... alternatives)
        If the upstream turns out to be empty, it keeps switching to the alternative sources until one of them is non-empty or there are no more alternatives remaining.
        Type Parameters:
        T - the input and output value type
        Parameters:
        alternatives - the array of alternative Publishers.
        Returns:
        the new FlowableTransformer instance
        Since:
        0.16.0
      • switchIfEmpty

        public static <T> FlowableTransformer<T,​T> switchIfEmpty​(java.lang.Iterable<? extends Publisher<? extends T>> alternatives)
        If the upstream turns out to be empty, it keeps switching to the alternative sources until one of them is non-empty or there are no more alternatives remaining.
        Type Parameters:
        T - the input and output value type
        Parameters:
        alternatives - the Iterable of alternative Publishers.
        Returns:
        the new FlowableTransformer instance
        Since:
        0.16.0
      • expand

        public static <T> FlowableTransformer<T,​T> expand​(Function<? super T,​? extends Publisher<? extends T>> expander)
        Emits elements from the source and then expands them into another layer of Publishers, emitting those items recursively until all Publishers become empty in a depth-first manner.
        Type Parameters:
        T - the value type
        Parameters:
        expander - the function that converts an element into a Publisher to be expanded
        Returns:
        the new FlwoableTransformer instance
        Since:
        0.16.1
      • expand

        public static <T> FlowableTransformer<T,​T> expand​(Function<? super T,​? extends Publisher<? extends T>> expander,
                                                                ExpandStrategy strategy)
        Emits elements from the source and then expands them into another layer of Publishers, emitting those items recursively until all Publishers become empty with the specified strategy.
        Type Parameters:
        T - the value type
        Parameters:
        expander - the function that converts an element into a Publisher to be expanded
        strategy - the expansion strategy; depth-first will recursively expand the first item until there is no more expansion possible, then the second items, and so on; breadth-first will first expand the main source, then runs the expaned Publishers in sequence, then the 3rd level, and so on.
        Returns:
        the new FlwoableTransformer instance
        Since:
        0.16.1
      • expand

        public static <T> FlowableTransformer<T,​T> expand​(Function<? super T,​? extends Publisher<? extends T>> expander,
                                                                ExpandStrategy strategy,
                                                                int capacityHint)
        Emits elements from the source and then expands them into another layer of Publishers, emitting those items recursively until all Publishers become empty with the specified strategy.
        Type Parameters:
        T - the value type
        Parameters:
        expander - the function that converts an element into a Publisher to be expanded
        strategy - the expansion strategy; depth-first will recursively expand the first item until there is no more expansion possible, then the second items, and so on; breadth-first will first expand the main source, then runs the expaned Publishers in sequence, then the 3rd level, and so on.
        capacityHint - the capacity hint for the breadth-first expansion
        Returns:
        the new FlwoableTransformer instance
        Since:
        0.16.1
      • expandDelayError

        public static <T> FlowableTransformer<T,​T> expandDelayError​(Function<? super T,​? extends Publisher<? extends T>> expander)
        Emits elements from the source and then expands them into another layer of Publishers, emitting those items recursively until all Publishers become empty in a depth-first manner, delaying errors until all sources terminate.
        Type Parameters:
        T - the value type
        Parameters:
        expander - the function that converts an element into a Publisher to be expanded
        Returns:
        the new FlwoableTransformer instance
        Since:
        0.18.4
      • expandDelayError

        public static <T> FlowableTransformer<T,​T> expandDelayError​(Function<? super T,​? extends Publisher<? extends T>> expander,
                                                                          ExpandStrategy strategy)
        Emits elements from the source and then expands them into another layer of Publishers, emitting those items recursively until all Publishers become empty with the specified strategy, delaying errors until all sources terminate.
        Type Parameters:
        T - the value type
        Parameters:
        expander - the function that converts an element into a Publisher to be expanded
        strategy - the expansion strategy; depth-first will recursively expand the first item until there is no more expansion possible, then the second items, and so on; breadth-first will first expand the main source, then runs the expaned Publishers in sequence, then the 3rd level, and so on.
        Returns:
        the new FlwoableTransformer instance
        Since:
        0.18.4
      • expandDelayError

        public static <T> FlowableTransformer<T,​T> expandDelayError​(Function<? super T,​? extends Publisher<? extends T>> expander,
                                                                          ExpandStrategy strategy,
                                                                          int capacityHint)
        Emits elements from the source and then expands them into another layer of Publishers, emitting those items recursively until all Publishers become empty with the specified strategy, delaying errors until all sources terminate.
        Type Parameters:
        T - the value type
        Parameters:
        expander - the function that converts an element into a Publisher to be expanded
        strategy - the expansion strategy; depth-first will recursively expand the first item until there is no more expansion possible, then the second items, and so on; breadth-first will first expand the main source, then runs the expaned Publishers in sequence, then the 3rd level, and so on.
        capacityHint - the capacity hint for the breadth-first expansion
        Returns:
        the new FlwoableTransformer instance
        Since:
        0.18.4
      • mapAsync

        public static <T,​R> FlowableTransformer<T,​R> mapAsync​(Function<? super T,​? extends Publisher<? extends R>> mapper)
        Maps each upstream value into a single value provided by a generated Publisher for that input value to be emitted to downstream.

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

        The inner Publishers 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 Publisher that should emit a single value to be emitted.
        Returns:
        the new FlowableTransformer instance
        Since:
        0.16.2
      • mapAsync

        public static <T,​R> FlowableTransformer<T,​R> mapAsync​(Function<? super T,​? extends Publisher<? extends R>> mapper,
                                                                          int bufferSize)
        Maps each upstream value into a single value provided by a generated Publisher for that input value to be emitted to downstream.

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

        The inner Publishers 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 Publisher
        bufferSize - the internal buffer size and prefetch amount to buffer items from upstream until their turn comes up that should emit a single value to be emitted.
        Returns:
        the new FlowableTransformer instance
        Since:
        0.16.2
      • mapAsync

        public static <T,​U,​R> FlowableTransformer<T,​R> mapAsync​(Function<? super T,​? extends Publisher<? extends U>> mapper,
                                                                                  BiFunction<? super T,​? super U,​? extends R> combiner)
        Maps each upstream value into a single value provided by a generated Publisher 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 Publisher's are considered. If the inner Publisher is empty, no resulting item is generated for that input value.

        The inner Publishers 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 Publisher 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 Publisher and returns a result value to be emitted to downstream.
        Returns:
        the new FlowableTransformer instance
        Since:
        0.16.2
      • mapAsync

        public static <T,​U,​R> FlowableTransformer<T,​R> mapAsync​(Function<? super T,​? extends Publisher<? extends U>> mapper,
                                                                                  BiFunction<? super T,​? super U,​? extends R> combiner,
                                                                                  int bufferSize)
        Maps each upstream value into a single value provided by a generated Publisher 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 Publisher's are considered. If the inner Publisher is empty, no resulting item is generated for that input value.

        The inner Publishers 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 Publisher 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 Publisher and returns a result value to be emitted to downstream.
        bufferSize - the internal buffer size and prefetch amount to buffer items from upstream until their turn comes up
        Returns:
        the new FlowableTransformer instance
        Since:
        0.16.2
      • filterAsync

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

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

        The inner Publishers 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 Publisher that should emit a single true to indicate the original value should pass.
        Returns:
        the new FlowableTransformer instance
        Since:
        0.16.2
      • filterAsync

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

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

        The inner Publishers 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 Publisher 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 FlowableTransformer instance
        Since:
        0.16.2
      • coalesce

        public static <T,​R> FlowableTransformer<T,​R> coalesce​(Supplier<R> containerSupplier,
                                                                          BiConsumer<R,​T> coalescer)
        Coalesces items from upstream into a container via a consumer and emits the container if there is a downstream demand, otherwise it keeps coalescing into the same container.
        Type Parameters:
        T - the upstream value type
        R - the container and result type
        Parameters:
        containerSupplier - the function called and should return a fresh container to coalesce into
        coalescer - the consumer receiving the current container and upstream item to handle
        Returns:
        the new FlowableTransformer instance
        Since:
        0.17.3
      • coalesce

        public static <T,​R> FlowableTransformer<T,​R> coalesce​(Supplier<R> containerSupplier,
                                                                          BiConsumer<R,​T> coalescer,
                                                                          int bufferSize)
        Coalesces items from upstream into a container via a consumer and emits the container if there is a downstream demand, otherwise it keeps coalescing into the same container.
        Type Parameters:
        T - the upstream value type
        R - the container and result type
        Parameters:
        containerSupplier - the function called and should return a fresh container to coalesce into
        coalescer - the consumer receiving the current container and upstream item to handle
        bufferSize - the island size of the internal unbounded buffer
        Returns:
        the new FlowableTransformer instance
        Since:
        0.17.3
      • windowWhile

        @SchedulerSupport("none")
        @BackpressureSupport(FULL)
        public static <T> FlowableTransformer<T,​Flowable<T>> windowWhile​(Predicate<? super T> predicate)
        Emits elements into a Flowable window while the given predicate returns true. If the predicate returns false, a new Flowable window is emitted.
        Type Parameters:
        T - the source value type
        Parameters:
        predicate - the predicate receiving the current value and if returns false, a new window is created with the specified item
        Returns:
        the new FlowableTransformer instance
        Since:
        0.17.7
      • windowWhile

        @SchedulerSupport("none")
        @BackpressureSupport(FULL)
        public static <T> FlowableTransformer<T,​Flowable<T>> windowWhile​(Predicate<? super T> predicate,
                                                                               int bufferSize)
        Emits elements into a Flowable window while the given predicate returns true. If the predicate returns false, a new Flowable window is emitted.
        Type Parameters:
        T - the source value type
        Parameters:
        predicate - the predicate receiving the current value and if returns false, a new window is created with the specified item
        bufferSize - the buffer size hint (the chunk size of the underlying unbounded buffer)
        Returns:
        the new FlowableTransformer instance
        Since:
        0.17.7
      • windowUntil

        @SchedulerSupport("none")
        @BackpressureSupport(FULL)
        public static <T> FlowableTransformer<T,​Flowable<T>> windowUntil​(Predicate<? super T> predicate)
        Emits elements into a Flowable window until the given predicate returns true at which point a new Flowable window is emitted.
        Type Parameters:
        T - the source value type
        Parameters:
        predicate - the predicate receiving the current item and if returns true, the current window is completed and a new window is emitted
        Returns:
        the new FlowableTransformer instance
        Since:
        0.17.7
      • windowUntil

        @SchedulerSupport("none")
        @BackpressureSupport(FULL)
        public static <T> FlowableTransformer<T,​Flowable<T>> windowUntil​(Predicate<? super T> predicate,
                                                                               int bufferSize)
        Emits elements into a Flowable window until the given predicate returns true at which point a new Flowable window is emitted.
        Type Parameters:
        T - the source value type
        Parameters:
        predicate - the predicate receiving the current item and if returns true, the current window is completed and a new window is emitted
        bufferSize - the buffer size hint (the chunk size of the underlying unbounded buffer)
        Returns:
        the new Flowable instance
        Since:
        0.17.7
      • windowSplit

        @SchedulerSupport("none")
        @BackpressureSupport(FULL)
        public static <T> FlowableTransformer<T,​Flowable<T>> windowSplit​(Predicate<? super T> predicate)
        Emits elements into a Flowable window until the given predicate returns true at which point a new Flowable window is emitted; the particular item will be dropped.
        Type Parameters:
        T - the source value type
        Parameters:
        predicate - the predicate receiving the current item and if returns true, the current window is completed and a new window is emitted
        Returns:
        the new FlowableTransformer instance
        Since:
        0.17.7
      • windowSplit

        @SchedulerSupport("none")
        @BackpressureSupport(FULL)
        public static <T> FlowableTransformer<T,​Flowable<T>> windowSplit​(Predicate<? super T> predicate,
                                                                               int bufferSize)
        Emits elements into a Flowable window until the given predicate returns true at which point a new Flowable window is emitted; the particular item will be dropped.
        Type Parameters:
        T - the source value type
        Parameters:
        predicate - the predicate receiving the current item and if returns true, the current window is completed and a new window is emitted
        bufferSize - the buffer size hint (the chunk size of the underlying unbounded buffer)
        Returns:
        the new FlowableTransformer instance
        Since:
        0.17.7
      • indexOf

        @SchedulerSupport("none")
        @BackpressureSupport(UNBOUNDED_IN)
        public static <T> FlowableTransformer<T,​java.lang.Long> indexOf​(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 FlowableTransformer instance
        Since:
        0.18.2
      • requestObserveOn

        @SchedulerSupport("custom")
        @BackpressureSupport(FULL)
        public static <T> FlowableTransformer<T,​T> requestObserveOn​(Scheduler scheduler)
        Requests items one-by-one from the upstream from the given Scheduler and emits those items received on the same Scheduler, allowing a more interleaved usage of the target Scheduler (aka "fair" use).

        It behaves similar to Flowable.observeOn(Scheduler) except it requests items one-by-one from the upstream and this request is issued from the give Scheduler thread as an individual Runnable task. Each item received from the upstream will also run on the given Scheduler as individual Runnable tasks which should maximize the possibility of work interleaved on a threadpool-backed Scheduler such as Schedulers.computation().

        Backpressure:
        The operator requests one item at a time and requests the next item once the downstream has been notified of the previous one. If the upstream ignores backpressure, this operator will randomly drop items similar to Flowable.onBackpressureLatest().
        Scheduler:
        You specify the Scheduler this operator should use.
        Type Parameters:
        T - the item type
        Parameters:
        scheduler - the scheduler to use for requesting from the upstream and re-emitting those items from
        Returns:
        the new FlowableTransformer instance
        Since:
        0.18.6
      • requestSample

        @SchedulerSupport("custom")
        @BackpressureSupport(ERROR)
        public static <T> FlowableTransformer<T,​T> requestSample​(long period,
                                                                       java.util.concurrent.TimeUnit unit,
                                                                       Scheduler scheduler)
        Issues a request(1) to the upstream repeatedly after the given period time elapses (including the very first request(1)).
        Backpressure:
        The operator issues request(1) to its upstream periodically and expects the downstream to be ready to consume the items. If the downstream is not ready at that moment, a MissingBackpressureException is signalled and the flow is cancelled.
        Scheduler:
        You specify the Scheduler this operator should use for issuing each request(1) call. Note that this may trigger the item creation on the specified scheduler.
        Type Parameters:
        T - the item type
        Parameters:
        period - the time between the request(1) calls
        unit - the unit of measure
        scheduler - the source of the period ticks that issue each request(1) calls
        Returns:
        the new FlowableTransformer instance
        Since:
        0.18.6
      • requestSample

        public static <T> FlowableTransformer<T,​T> requestSample​(long initialDelay,
                                                                       long period,
                                                                       java.util.concurrent.TimeUnit unit,
                                                                       Scheduler scheduler)
        Issues a request(1) to the upstream after an initial delay, then repeatedly by given period.
        Backpressure:
        The operator issues request(1) to its upstream after an initial delay, then periodically and expects the downstream to be ready to consume the items. If the downstream is not ready at that moment, a MissingBackpressureException is signalled and the flow is cancelled.
        Scheduler:
        You specify the Scheduler this operator should use for issuing each request(1) call. Note that this may trigger the item creation on the specified scheduler.
        Type Parameters:
        T - the item type
        Parameters:
        initialDelay - the initial delay before the very first request(1).
        period - the time between the subsequent request(1) calls
        unit - the unit of measure
        scheduler - the source of the period ticks that issue each request(1) calls
        Returns:
        the new FlowableTransformer instance
        Since:
        0.18.6
      • requestSample

        public static <T,​U> FlowableTransformer<T,​T> requestSample​(Publisher<U> other)
        Issues a request(1) to the upstream when the other Publisher signals an onNext.

        If the other Publisher signals an onError or onComplete, the flow is terminated with the respective signal as well.

        Backpressure:
        The operator issues request(1) when the other Publisher signals an onNext and expects the downstream to be ready to consume the items. If the downstream is not ready at that moment, a MissingBackpressureException is signalled and the flow is cancelled. The other Publisher is consumed in an unbounded manner.
        Scheduler:
        This operator doesn't run on any particular Scheduler.
        Type Parameters:
        T - the item type
        U - the item type of the other source, the items are ignored and dropped
        Parameters:
        other - the other Publisher instance that should signal onNext to request 1 item from the main source.
        Returns:
        the new FlowableTransformer instance
        Since:
        0.18.6
      • partialCollect

        public static <T,​I,​A,​R> FlowableTransformer<T,​R> partialCollect​(Consumer<? super PartialCollectEmitter<T,​I,​A,​R>> handler,
                                                                                                Consumer<? super T> cleaner,
                                                                                                int prefetch)
        Allows converting upstream items into output objects where an upstream item may represent such output objects partially or may represent more than one output object.

        For example, given a stream of byte[] where each array could contain part of a larger object, and thus more than one subsequent arrays are required to construct the output object. The same array could also contain more than one output items, therefore, it should be kept around in case the output is backpressured.

        Type Parameters:
        T - the upstream value type
        I - the type that indicates where the first cached item should be read from
        A - the accumulator type used to collect up partial data
        R - the output type
        Parameters:
        handler - the handler called when there was a change in the operators state: new upstream items became available or the downstream requested
        cleaner - called to clean up the upstream items consumed
        prefetch - The number of items to fetch from the upstream to keep the operator busy. Note that if more than this number of items are required by the handler to create an output item, the operator may hang if the handler doesn't consume the upstream items containing the partial items.
        Returns:
        the new FlowableTransformer instance
        Since:
        0.18.9
      • errorJump

        public static <T,​R> FlowableTransformer<T,​R> errorJump​(FlowableTransformer<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
      • switchOnFirst

        public static <T> FlowableTransformer<T,​T> switchOnFirst​(Predicate<? super T> predicate,
                                                                       Function<? super T,​? extends Publisher<? extends T>> selector)
        Switches to an alternate flow if the very first item of the main flow matches the given predicate.

        Note that the very first item is not included in the follow-up sequence if the switch happens. Use Flowable.startWithItem(Object) to add it back if necessary.

        Type Parameters:
        T - the element type of the selected flow
        Parameters:
        predicate - a predicate that receives the very first item and should return true to indicate to switch streams. If the predicate returns false, the main sequence is streamed till its end.
        selector - if the predicate returned true, the function is called with the very first item and should return a flow to resume with.
        Returns:
        the new FlowableTransformer instance
        Since:
        0.20.7