public final class FlowableTransformers extends Object
FlowableTransformer
,
use Flowable.compose(FlowableTransformer)
to apply the operators to an existing sequence.Modifier and Type | Method and Description |
---|---|
static <T> FlowableTransformer<T,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 Collection<? super T>> |
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,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 Collection<? super T>> |
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,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 Collection<? super T>> |
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,
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,
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<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<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,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,
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,
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,
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,
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,
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,
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)
|
static <T> FlowableTransformer<T,T> |
spanout(long initialDelay,
long betweenDelay,
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,
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,
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,
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,
TimeUnit unit)
Inserts a time delay between emissions from the upstream source.
|
static <T> FlowableTransformer<T,T> |
spanout(long betweenDelay,
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,
TimeUnit unit,
Scheduler scheduler)
Inserts a time delay between emissions from the upstream source.
|
static <T> FlowableTransformer<T,T> |
spanout(long betweenDelay,
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(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,
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,
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,
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,
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<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<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<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.
|
@SchedulerSupport(value="none") @BackpressureSupport(value=PASS_THROUGH) public static <T> FlowableTransformer<T,T> valve(Publisher<Boolean> other)
Properties:
IllegalStateException
.Scheduler
.Flowable.bufferSize()
to hold onto values if the valve is closed.T
- the value type of the main sourceother
- the other sourceNullPointerException
- if other
is null@SchedulerSupport(value="none") @BackpressureSupport(value=PASS_THROUGH) public static <T> FlowableTransformer<T,T> valve(Publisher<Boolean> other, boolean defaultOpen)
Properties:
IllegalStateException
.Scheduler
.Flowable.bufferSize()
to hold onto values if the valve is closed.T
- the value type of the main sourceother
- the other sourcedefaultOpen
- should the valve start as open?NullPointerException
- if other
is null@SchedulerSupport(value="none") @BackpressureSupport(value=PASS_THROUGH) public static <T> FlowableTransformer<T,T> valve(Publisher<Boolean> other, boolean defaultOpen, int bufferSize)
Properties:
IllegalStateException
.Scheduler
.T
- the value type of the main sourceother
- the other sourcedefaultOpen
- should the valve start as open?bufferSize
- the buffer size hint (the chunk size of the underlying unbounded buffer)IllegalArgumentException
- if bufferSize <= 0NullPointerException
- if other
is null@SchedulerSupport(value="none") @BackpressureSupport(value=FULL) public static <T> FlowableTransformer<T,List<T>> bufferWhile(Predicate<? super T> predicate)
T
- the source value typepredicate
- the predicate receiving the current value and if returns false,
a new buffer is created with the specified item@SchedulerSupport(value="none") @BackpressureSupport(value=FULL) public static <T,C extends Collection<? super T>> FlowableTransformer<T,C> bufferWhile(Predicate<? super T> predicate, Supplier<C> bufferSupplier)
T
- the source value typeC
- the collection typepredicate
- the predicate receiving the current value and if returns false,
a new collection is created with the specified itembufferSupplier
- the supplier that returns a fresh collection@SchedulerSupport(value="none") @BackpressureSupport(value=FULL) public static <T> FlowableTransformer<T,List<T>> bufferUntil(Predicate<? super T> predicate)
T
- the source value typepredicate
- the predicate receiving the current item and if returns true,
the current buffer is emitted and a fresh empty buffer is created@SchedulerSupport(value="none") @BackpressureSupport(value=FULL) public static <T,C extends Collection<? super T>> FlowableTransformer<T,C> bufferUntil(Predicate<? super T> predicate, Supplier<C> bufferSupplier)
T
- the source value typeC
- the collection typepredicate
- the predicate receiving the current item and if returns true,
the current collection is emitted and a fresh empty collection is createdbufferSupplier
- the supplier that returns a fresh collection@SchedulerSupport(value="none") @BackpressureSupport(value=FULL) public static <T> FlowableTransformer<T,List<T>> bufferSplit(Predicate<? super T> predicate)
T
- the source value typepredicate
- the predicate receiving the current item and if returns true,
the current buffer is emitted and a fresh empty buffer is created@SchedulerSupport(value="none") @BackpressureSupport(value=FULL) public static <T,C extends Collection<? super T>> FlowableTransformer<T,C> bufferSplit(Predicate<? super T> predicate, Supplier<C> bufferSupplier)
T
- the source value typeC
- the collection typepredicate
- the predicate receiving the current item and if returns true,
the current collection is emitted and a fresh empty collection is createdbufferSupplier
- the Supplier that returns a fresh collection@BackpressureSupport(value=PASS_THROUGH) @SchedulerSupport(value="io.reactivex:computation") public static <T> FlowableTransformer<T,T> spanout(long betweenDelay, TimeUnit unit)
Scheduler
.T
- the value typebetweenDelay
- the (minimum) delay time between elementsunit
- the time unit of the initial delay and the between delay values@BackpressureSupport(value=PASS_THROUGH) @SchedulerSupport(value="custom") public static <T> FlowableTransformer<T,T> spanout(long betweenDelay, TimeUnit unit, Scheduler scheduler)
Scheduler
you provide.T
- the value typebetweenDelay
- the (minimum) delay time between elementsunit
- the time unit of the initial delay and the between delay valuesscheduler
- the scheduler to delay and emit the values on@BackpressureSupport(value=PASS_THROUGH) @SchedulerSupport(value="io.reactivex:computation") public static <T> FlowableTransformer<T,T> spanout(long initialDelay, long betweenDelay, TimeUnit unit)
Scheduler
.T
- the value typeinitialDelay
- the initial delaybetweenDelay
- the (minimum) delay time between elementsunit
- the time unit of the initial delay and the between delay values@BackpressureSupport(value=PASS_THROUGH) @SchedulerSupport(value="custom") public static <T> FlowableTransformer<T,T> spanout(long initialDelay, long betweenDelay, TimeUnit unit, Scheduler scheduler)
Scheduler
you provide.T
- the value typeinitialDelay
- the initial delaybetweenDelay
- the (minimum) delay time between elementsunit
- the time unit of the initial delay and the between delay valuesscheduler
- the scheduler to delay and emit the values on@BackpressureSupport(value=PASS_THROUGH) @SchedulerSupport(value="io.reactivex:computation") public static <T> FlowableTransformer<T,T> spanout(long betweenDelay, TimeUnit unit, boolean delayError)
Scheduler
.T
- the value typebetweenDelay
- the (minimum) delay time between elementsunit
- the time unit of the initial delay and the between delay valuesdelayError
- delay the onError event from upstream@BackpressureSupport(value=PASS_THROUGH) @SchedulerSupport(value="custom") public static <T> FlowableTransformer<T,T> spanout(long betweenDelay, TimeUnit unit, Scheduler scheduler, boolean delayError)
Scheduler
you provide.T
- the value typebetweenDelay
- the (minimum) delay time between elementsunit
- the time unit of the initial delay and the between delay valuesscheduler
- the scheduler to delay and emit the values ondelayError
- delay the onError event from upstream@BackpressureSupport(value=PASS_THROUGH) @SchedulerSupport(value="io.reactivex:computation") public static <T> FlowableTransformer<T,T> spanout(long initialDelay, long betweenDelay, TimeUnit unit, boolean delayError)
Scheduler
.T
- the value typeinitialDelay
- the initial delaybetweenDelay
- the (minimum) delay time between elementsunit
- the time unit of the initial delay and the between delay valuesdelayError
- delay the onError event from upstream@BackpressureSupport(value=PASS_THROUGH) @SchedulerSupport(value="custom") public static <T> FlowableTransformer<T,T> spanout(long initialDelay, long betweenDelay, TimeUnit unit, Scheduler scheduler, boolean delayError)
Scheduler
you provide.T
- the value typeinitialDelay
- the initial delaybetweenDelay
- the (minimum) delay time between elementsunit
- the time unit of the initial delay and the between delay valuesscheduler
- the scheduler to delay and emit the values ondelayError
- delay the onError event from upstream@BackpressureSupport(value=PASS_THROUGH) @SchedulerSupport(value="none") public static <T,R> FlowableTransformer<T,R> mapFilter(BiConsumer<? super T,? super BasicEmitter<R>> consumer)
T
- the input value typeR
- the output value typeconsumer
- 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).@BackpressureSupport(value=UNBOUNDED_IN) @SchedulerSupport(value="io.reactivex:computation") public static <T> FlowableTransformer<T,T> onBackpressureTimeout(long timeout, TimeUnit unit)
T
- the value typetimeout
- the maximum age of an element in the bufferunit
- the time unit of the timeoutfor more options
@BackpressureSupport(value=UNBOUNDED_IN) @SchedulerSupport(value="custom") public static <T> FlowableTransformer<T,T> onBackpressureTimeout(long timeout, TimeUnit unit, Scheduler scheduler, Consumer<? super T> onEvict)
T
- the value typetimeout
- the maximum age of an element in the bufferunit
- the time unit of the timeoutscheduler
- the scheduler to be used as time source and to trigger the timeout & evictiononEvict
- called when an element is evicted, maybe concurrently@BackpressureSupport(value=UNBOUNDED_IN) @SchedulerSupport(value="custom") public static <T> FlowableTransformer<T,T> onBackpressureTimeout(long timeout, TimeUnit unit, Scheduler scheduler)
T
- the value typetimeout
- the maximum age of an element in the bufferunit
- the time unit of the timeoutscheduler
- the scheduler to be used as time source and to trigger the timeout & evictionfor more options
@BackpressureSupport(value=UNBOUNDED_IN) @SchedulerSupport(value="custom") public static <T> FlowableTransformer<T,T> onBackpressureTimeout(int maxSize, long timeout, TimeUnit unit, Scheduler scheduler, Consumer<? super T> onEvict)
T
- the value typemaxSize
- the maximum number of elements in the buffer, beyond that,
the oldest element is evictedtimeout
- the maximum age of an element in the bufferunit
- the time unit of the timeoutscheduler
- the scheduler to be used as time source and to trigger the timeout & evictiononEvict
- called when an element is evicted, maybe concurrently@BackpressureSupport(value=SPECIAL) @SchedulerSupport(value="none") public static <T> FlowableTransformer<T,T> every(long keep)
times
what the downstream requests and skips @code keep-1} items.Scheduler
.T
- the value typekeep
- the period of items to keep, i.e., this minus one items will be dropped
before emitting an item directly@BackpressureSupport(value=UNBOUNDED_IN) @SchedulerSupport(value="none") public static <T> FlowableTransformer<T,T> cacheLast()
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.
T
- the value type emitted@BackpressureSupport(value=UNBOUNDED_IN) @SchedulerSupport(value="io.reactivex:computation") public static <T> FlowableTransformer<T,T> timeoutLast(long timeout, TimeUnit unit)
T
- the value typetimeout
- the timeout valueunit
- the timeout time unit@BackpressureSupport(value=UNBOUNDED_IN) @SchedulerSupport(value="custom") public static <T> FlowableTransformer<T,T> timeoutLast(long timeout, TimeUnit unit, Scheduler scheduler)
T
- the value typetimeout
- the timeout valueunit
- the timeout time unitscheduler
- the scheduler to run the timeout and possible emit the last/latest@BackpressureSupport(value=UNBOUNDED_IN) @SchedulerSupport(value="io.reactivex:computation") public static <T> FlowableTransformer<T,T> timeoutLastAbsolute(long timeout, TimeUnit unit)
T
- the value typetimeout
- the timeout valueunit
- the timeout time unit@BackpressureSupport(value=UNBOUNDED_IN) @SchedulerSupport(value="custom") public static <T> FlowableTransformer<T,T> timeoutLastAbsolute(long timeout, TimeUnit unit, Scheduler scheduler)
T
- the value typetimeout
- the timeout valueunit
- the timeout time unitscheduler
- the scheduler to run the timeout and possible emit the last/latest@BackpressureSupport(value=PASS_THROUGH) @SchedulerSupport(value="io.reactivex:computation") public static <T> FlowableTransformer<T,T> debounceFirst(long timeout, TimeUnit unit)
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.
T
- the value typetimeout
- the timeoutunit
- the unit of measure of the timeout parameter@BackpressureSupport(value=PASS_THROUGH) @SchedulerSupport(value="custom") public static <T> FlowableTransformer<T,T> debounceFirst(long timeout, TimeUnit unit, Scheduler scheduler)
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.
T
- the value typetimeout
- the timeoutunit
- the unit of measure of the timeout parameterscheduler
- the scheduler used for getting the current time when
evaluating upstream items@BackpressureSupport(value=FULL) @SchedulerSupport(value="none") public static <T,R> FlowableTransformer<T,R> switchFlatMap(Function<? super T,? extends Publisher<? extends R>> mapper, int maxActive)
T
- the source value typeR
- the result value typemapper
- the function that maps an upstream value into a Publisher to be merged/switchedmaxActive
- the maximum number of active inner Publishers@BackpressureSupport(value=FULL) @SchedulerSupport(value="none") public static <T,R> FlowableTransformer<T,R> switchFlatMap(Function<? super T,? extends Publisher<? extends R>> mapper, int maxActive, int bufferSize)
T
- the source value typeR
- the result value typemapper
- the function that maps an upstream value into a Publisher to be merged/switchedmaxActive
- the maximum number of active inner PublishersbufferSize
- the number of items to prefetch from each inner sourcepublic static <T,R> FlowableTransformer<T,R> flatMapSync(Function<? super T,? extends Publisher<? extends R>> mapper)
T
- the input value typeR
- the result value typemapper
- the function mapping from a value into a Publisherpublic static <T,R> FlowableTransformer<T,R> flatMapSync(Function<? super T,? extends Publisher<? extends R>> mapper, boolean depthFirst)
T
- the input value typeR
- the result value typemapper
- the function mapping from a value into a PublisherdepthFirst
- if true, the inner sources are drained as much as possible
if false, the inner sources are consumed in a round-robin fashionpublic static <T,R> FlowableTransformer<T,R> flatMapSync(Function<? super T,? extends Publisher<? extends R>> mapper, int maxConcurrency, int bufferSize, boolean depthFirst)
T
- the input value typeR
- the result value typemapper
- the function mapping from a value into a PublishermaxConcurrency
- the maximum number of sources merged at oncebufferSize
- the prefetch on each inner sourcedepthFirst
- if true, the inner sources are drained as much as possible
if false, the inner sources are consumed in a round-robin fashionpublic static <T,R> FlowableTransformer<T,R> flatMapAsync(Function<? super T,? extends Publisher<? extends R>> mapper, Scheduler scheduler)
This operator can be considered as a fusion between a flatMapSync and observeOn.
T
- the input value typeR
- the output value typemapper
- the function mapping from a value into a Publisherscheduler
- the Scheduler to use to collect and emit merged itemspublic static <T,R> FlowableTransformer<T,R> flatMapAsync(Function<? super T,? extends Publisher<? extends R>> mapper, Scheduler scheduler, boolean depthFirst)
This operator can be considered as a fusion between a flatMapSync and observeOn.
T
- the input value typeR
- the output value typemapper
- the function mapping from a value into a Publisherscheduler
- the Scheduler to use to collect and emit merged itemsdepthFirst
- if true, the inner sources are drained as much as possible
if false, the inner sources are consumed in a round-robin fashionpublic static <T,R> FlowableTransformer<T,R> flatMapAsync(Function<? super T,? extends Publisher<? extends R>> mapper, Scheduler scheduler, int maxConcurrency, int bufferSize, boolean depthFirst)
This operator can be considered as a fusion between a flatMapSync and observeOn.
T
- the input value typeR
- the output value typemapper
- the function mapping from a value into a Publisherscheduler
- the Scheduler to use to collect and emit merged itemsmaxConcurrency
- the maximum number of sources merged at oncebufferSize
- the prefetch on each inner sourcedepthFirst
- if true, the inner sources are drained as much as possible
if false, the inner sources are consumed in a round-robin fashion@SafeVarargs public static <T> FlowableTransformer<T,T> switchIfEmptyArray(Publisher<? extends T>... alternatives)
T
- the input and output value typealternatives
- the array of alternative Publishers.public static <T> FlowableTransformer<T,T> switchIfEmpty(Iterable<? extends Publisher<? extends T>> alternatives)
T
- the input and output value typealternatives
- the Iterable of alternative Publishers.public static <T> FlowableTransformer<T,T> expand(Function<? super T,? extends Publisher<? extends T>> expander)
T
- the value typeexpander
- the function that converts an element into a Publisher to be expandedpublic static <T> FlowableTransformer<T,T> expand(Function<? super T,? extends Publisher<? extends T>> expander, ExpandStrategy strategy)
T
- the value typeexpander
- the function that converts an element into a Publisher to be expandedstrategy
- 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.public static <T> FlowableTransformer<T,T> expand(Function<? super T,? extends Publisher<? extends T>> expander, ExpandStrategy strategy, int capacityHint)
T
- the value typeexpander
- the function that converts an element into a Publisher to be expandedstrategy
- 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 expansionpublic static <T> FlowableTransformer<T,T> expandDelayError(Function<? super T,? extends Publisher<? extends T>> expander)
T
- the value typeexpander
- the function that converts an element into a Publisher to be expandedpublic static <T> FlowableTransformer<T,T> expandDelayError(Function<? super T,? extends Publisher<? extends T>> expander, ExpandStrategy strategy)
T
- the value typeexpander
- the function that converts an element into a Publisher to be expandedstrategy
- 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.public static <T> FlowableTransformer<T,T> expandDelayError(Function<? super T,? extends Publisher<? extends T>> expander, ExpandStrategy strategy, int capacityHint)
T
- the value typeexpander
- the function that converts an element into a Publisher to be expandedstrategy
- 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 expansionpublic static <T,R> FlowableTransformer<T,R> mapAsync(Function<? super T,? extends Publisher<? extends R>> mapper)
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.
T
- the input value typeR
- the result value typemapper
- the function that receives the upstream value and returns a Publisher
that should emit a single value to be emitted.public static <T,R> FlowableTransformer<T,R> mapAsync(Function<? super T,? extends Publisher<? extends R>> mapper, int bufferSize)
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.
T
- the input value typeR
- the result value typemapper
- the function that receives the upstream value and returns a PublisherbufferSize
- 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.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)
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.
T
- the input value typeU
- the intermediate value typeR
- the result value typemapper
- 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.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)
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.
T
- the input value typeU
- the intermediate value typeR
- the result value typemapper
- 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 uppublic static <T> FlowableTransformer<T,T> filterAsync(Function<? super T,? extends Publisher<Boolean>> asyncPredicate)
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.
T
- the input and output value typeasyncPredicate
- the function that receives the upstream value and returns
a Publisher that should emit a single true to indicate the original value should pass.public static <T> FlowableTransformer<T,T> filterAsync(Function<? super T,? extends Publisher<Boolean>> asyncPredicate, int bufferSize)
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.
T
- the input and output value typeasyncPredicate
- 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 uppublic static <T,R> FlowableTransformer<T,R> coalesce(Supplier<R> containerSupplier, BiConsumer<R,T> coalescer)
T
- the upstream value typeR
- the container and result typecontainerSupplier
- the function called and should return a fresh container to coalesce intocoalescer
- the consumer receiving the current container and upstream item to handlepublic static <T,R> FlowableTransformer<T,R> coalesce(Supplier<R> containerSupplier, BiConsumer<R,T> coalescer, int bufferSize)
T
- the upstream value typeR
- the container and result typecontainerSupplier
- the function called and should return a fresh container to coalesce intocoalescer
- the consumer receiving the current container and upstream item to handlebufferSize
- the island size of the internal unbounded buffer@SchedulerSupport(value="none") @BackpressureSupport(value=FULL) public static <T> FlowableTransformer<T,Flowable<T>> windowWhile(Predicate<? super T> predicate)
T
- the source value typepredicate
- the predicate receiving the current value and if returns false,
a new window is created with the specified item@SchedulerSupport(value="none") @BackpressureSupport(value=FULL) public static <T> FlowableTransformer<T,Flowable<T>> windowWhile(Predicate<? super T> predicate, int bufferSize)
T
- the source value typepredicate
- the predicate receiving the current value and if returns false,
a new window is created with the specified itembufferSize
- the buffer size hint (the chunk size of the underlying unbounded buffer)@SchedulerSupport(value="none") @BackpressureSupport(value=FULL) public static <T> FlowableTransformer<T,Flowable<T>> windowUntil(Predicate<? super T> predicate)
T
- the source value typepredicate
- the predicate receiving the current item and if returns true,
the current window is completed and a new window is emitted@SchedulerSupport(value="none") @BackpressureSupport(value=FULL) public static <T> FlowableTransformer<T,Flowable<T>> windowUntil(Predicate<? super T> predicate, int bufferSize)
T
- the source value typepredicate
- the predicate receiving the current item and if returns true,
the current window is completed and a new window is emittedbufferSize
- the buffer size hint (the chunk size of the underlying unbounded buffer)@SchedulerSupport(value="none") @BackpressureSupport(value=FULL) public static <T> FlowableTransformer<T,Flowable<T>> windowSplit(Predicate<? super T> predicate)
T
- the source value typepredicate
- the predicate receiving the current item and if returns true,
the current window is completed and a new window is emitted@SchedulerSupport(value="none") @BackpressureSupport(value=FULL) public static <T> FlowableTransformer<T,Flowable<T>> windowSplit(Predicate<? super T> predicate, int bufferSize)
T
- the source value typepredicate
- the predicate receiving the current item and if returns true,
the current window is completed and a new window is emittedbufferSize
- the buffer size hint (the chunk size of the underlying unbounded buffer)@SchedulerSupport(value="none") @BackpressureSupport(value=UNBOUNDED_IN) public static <T> FlowableTransformer<T,Long> indexOf(Predicate<? super T> predicate)
T
- the upstream element typepredicate
- the predicate called to test each item, returning true will
stop the sequence and return the current item index@SchedulerSupport(value="custom") @BackpressureSupport(value=FULL) public static <T> FlowableTransformer<T,T> requestObserveOn(Scheduler scheduler)
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()
.
Flowable.onBackpressureLatest()
.Scheduler
this operator should use.T
- the item typescheduler
- the scheduler to use for requesting from the upstream and re-emitting
those items from@SchedulerSupport(value="custom") @BackpressureSupport(value=ERROR) public static <T> FlowableTransformer<T,T> requestSample(long period, TimeUnit unit, Scheduler scheduler)
request(1)
to the upstream repeatedly after the given period time elapses (including
the very first request(1)
).
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
this operator should use for issuing each request(1)
call.
Note that this may trigger the item creation on the specified scheduler.T
- the item typeperiod
- the time between the request(1) callsunit
- the unit of measurescheduler
- the source of the period ticks that issue each request(1) callspublic static <T> FlowableTransformer<T,T> requestSample(long initialDelay, long period, TimeUnit unit, Scheduler scheduler)
request(1)
to the upstream after an initial delay, then repeatedly by given period.
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
this operator should use for issuing each request(1)
call.
Note that this may trigger the item creation on the specified scheduler.T
- the item typeinitialDelay
- the initial delay before the very first request(1)
.period
- the time between the subsequent request(1)
callsunit
- the unit of measurescheduler
- the source of the period ticks that issue each request(1) callspublic static <T,U> FlowableTransformer<T,T> requestSample(Publisher<U> other)
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.
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
.T
- the item typeU
- the item type of the other source, the items are ignored and droppedother
- the other Publisher
instance that should signal onNext
to request
1 item from the main source.public static <T,I,A,R> FlowableTransformer<T,R> partialCollect(Consumer<? super PartialCollectEmitter<T,I,A,R>> handler, Consumer<? super T> cleaner, int prefetch)
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.
T
- the upstream value typeI
- the type that indicates where the first cached item should be read fromA
- the accumulator type used to collect up partial dataR
- the output typehandler
- the handler called when there was a change in the operators state:
new upstream items became available or the downstream requestedcleaner
- called to clean up the upstream items consumedprefetch
- 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.public static <T,R> FlowableTransformer<T,R> errorJump(FlowableTransformer<T,R> transformer)
T
- the upstream value typeR
- the downstream value typetransformer
- the transformation applied to the flow on a per-Subscriber basispublic static <T> FlowableTransformer<T,T> switchOnFirst(Predicate<? super T> predicate, Function<? super T,? extends Publisher<? extends T>> selector)
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.
T
- the element type of the selected flowpredicate
- 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.