public final class ObservableTransformers extends Object
ObservableTransformer
,
use Observable.compose(ObservableTransformer)
to apply the operators to an existing sequence.Observables
Modifier and Type | Method and Description |
---|---|
static <T,R> ObservableTransformer<T,R> |
errorJump(ObservableTransformer<T,R> transformer)
Allows an upstream error to jump over an inner transformation and is
then reapplied once the inner transformation's returned Flowable terminates.
|
static <T> ObservableTransformer<T,T> |
filterAsync(Function<? super T,? extends ObservableSource<Boolean>> asyncPredicate)
Maps each upstream value into a single
true or false value provided by a generated ObservableSource for that
input value and emits the input value if the inner ObservableSource returned true . |
static <T> ObservableTransformer<T,T> |
filterAsync(Function<? super T,? extends ObservableSource<Boolean>> asyncPredicate,
int bufferSize)
Maps each upstream value into a single
true or false value provided by a generated ObservableSource for that
input value and emits the input value if the inner ObservableSource returned true . |
static <T,R> @NonNull ObservableTransformer<T,R> |
flatMapDrop(Function<? super T,? extends ObservableSource<? extends R>> mapper)
FlatMap only one
ObservableSource at a time and ignore upstream values until it terminates. |
static <T,R> @NonNull ObservableTransformer<T,R> |
flatMapLatest(Function<? super T,? extends ObservableSource<? extends R>> mapper)
FlatMap only one
ObservableSource at a time and keep the latest upstream value until it terminates
and resume with the ObservableSource mapped for that latest upstream value. |
static <T> @NonNull ObservableTransformer<T,Long> |
indexOf(@NonNull Predicate<? super T> predicate)
Returns the first index of an element that matches a predicate or -1L if no elements match.
|
static <T,R> ObservableTransformer<T,R> |
mapAsync(Function<? super T,? extends ObservableSource<? extends R>> mapper)
Maps each upstream value into a single value provided by a generated ObservableSource for that
input value, which is then emitted to the downstream.
|
static <T,R> ObservableTransformer<T,R> |
mapAsync(Function<? super T,? extends ObservableSource<? extends R>> mapper,
int capacityHint)
Maps each upstream value into a single value provided by a generated ObservableSource for that
input value, which is then emitted to the downstream.
|
static <T,U,R> ObservableTransformer<T,R> |
mapAsync(Function<? super T,? extends ObservableSource<? extends U>> mapper,
BiFunction<? super T,? super U,? extends R> combiner)
Maps each upstream value into a single value provided by a generated ObservableSource for that
input value and combines the original and generated single value into a final result item
to be emitted to downstream.
|
static <T,U,R> ObservableTransformer<T,R> |
mapAsync(Function<? super T,? extends ObservableSource<? extends U>> mapper,
BiFunction<? super T,? super U,? extends R> combiner,
int capacityHint)
Maps each upstream value into a single value provided by a generated ObservableSource for that
input value and combines the original and generated single value into a final result item
to be emitted to downstream.
|
static <T> @NonNull ObservableTransformer<T,T> |
observeOnDrop(@NonNull Scheduler scheduler)
Schedules the event emission on a
Scheduler and drops upstream values while
the onNext with the current item is executing on that scheduler. |
static <T> @NonNull ObservableTransformer<T,T> |
observeOnLatest(@NonNull Scheduler scheduler)
Schedules the event emission on a
Scheduler and keeps the latest upstream item
while the downstream's onNext is executing so that it will resume
with that latest value. |
static <T> ObservableTransformer<T,T> |
valve(ObservableSource<Boolean> other)
Relays values until the other ObservableSource signals false and resumes if the other
ObservableSource signals true again, like closing and opening a valve and not losing
any items from the main source.
|
static <T> ObservableTransformer<T,T> |
valve(ObservableSource<Boolean> other,
boolean defaultOpen)
Relays values until the other ObservableSource signals false and resumes if the other
ObservableSource signals true again, like closing and opening a valve and not losing
any items from the main source and starts with the specified valve state.
|
static <T> ObservableTransformer<T,T> |
valve(ObservableSource<Boolean> other,
boolean defaultOpen,
int bufferSize)
Relays values until the other ObservableSource signals false and resumes if the other
ObservableSource signals true again, like closing and opening a valve and not losing
any items from the main source and starts with the specified valve state and the specified
buffer size hint.
|
@SchedulerSupport(value="none") @CheckReturnValue @NonNull public static <T> @NonNull ObservableTransformer<T,Long> indexOf(@NonNull @NonNull 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") @CheckReturnValue @NonNull public static <T> @NonNull ObservableTransformer<T,T> observeOnDrop(@NonNull @NonNull Scheduler scheduler)
Scheduler
and drops upstream values while
the onNext
with the current item is executing on that scheduler.
Errors are delayed until all items that weren't dropped have been delivered.
T
- the element typescheduler
- the scheduler to use for emitting events onobserveOnLatest(Scheduler)
@SchedulerSupport(value="custom") @CheckReturnValue @NonNull public static <T> @NonNull ObservableTransformer<T,T> observeOnLatest(@NonNull @NonNull Scheduler scheduler)
Scheduler
and keeps the latest upstream item
while the downstream's onNext
is executing so that it will resume
with that latest value.
Errors are delayed until the very last item has been delivered.
T
- the element typescheduler
- the scheduler to use for emitting events onobserveOnLatest(Scheduler)
@SchedulerSupport(value="none") @CheckReturnValue @NonNull public static <T,R> @NonNull ObservableTransformer<T,R> flatMapDrop(Function<? super T,? extends ObservableSource<? extends R>> mapper)
ObservableSource
at a time and ignore upstream values until it terminates.
Errors are delayed until both the upstream and the active inner ObservableSource
terminate.
T
- the upstream value typeR
- the output typemapper
- the function that takes an upstream item and returns a ObservableSource
to be run exclusively until it finishes@SchedulerSupport(value="none") @CheckReturnValue @NonNull public static <T,R> @NonNull ObservableTransformer<T,R> flatMapLatest(Function<? super T,? extends ObservableSource<? extends R>> mapper)
ObservableSource
at a time and keep the latest upstream value until it terminates
and resume with the ObservableSource
mapped for that latest upstream value.
Errors are delayed until both the upstream and the active inner ObservableSource
terminate.
T
- the upstream value typeR
- the output typemapper
- the function that takes an upstream item and returns a ObservableSource
to be run exclusively until it finishespublic static <T,R> ObservableTransformer<T,R> errorJump(ObservableTransformer<T,R> transformer)
T
- the upstream value typeR
- the downstream value typetransformer
- the transformation applied to the flow on a per-Subscriber basis@SchedulerSupport(value="none") public static <T> ObservableTransformer<T,T> valve(ObservableSource<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") public static <T> ObservableTransformer<T,T> valve(ObservableSource<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") public static <T> ObservableTransformer<T,T> valve(ObservableSource<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 nullpublic static <T,R> ObservableTransformer<T,R> mapAsync(Function<? super T,? extends ObservableSource<? extends R>> mapper)
Only the first item emitted by the inner ObservableSource are considered. If the inner ObservableSource is empty, no resulting item is generated for that input value.
The inner ObservableSources are consumed in order and one at a time.
T
- the input value typeR
- the result value typemapper
- the function that receives the upstream value and returns a ObservableSource
that should emit a single value to be emitted.public static <T,R> ObservableTransformer<T,R> mapAsync(Function<? super T,? extends ObservableSource<? extends R>> mapper, int capacityHint)
Only the first item emitted by the inner ObservableSource are considered. If the inner ObservableSource is empty, no resulting item is generated for that input value.
The inner ObservableSources are consumed in order and one at a time.
T
- the input value typeR
- the result value typemapper
- the function that receives the upstream value and returns a ObservableSource
that should emit a single value to be emitted.capacityHint
- the number of items expected from the upstream to be buffered while each
inner ObservableSource is executing.public static <T,U,R> ObservableTransformer<T,R> mapAsync(Function<? super T,? extends ObservableSource<? extends U>> mapper, BiFunction<? super T,? super U,? extends R> combiner)
Only the first item emitted by the inner ObservableSource are considered. If the inner ObservableSource is empty, no resulting item is generated for that input value.
The inner ObservableSources are consumed in order and one at a time.
T
- the input value typeU
- the intermediate value typeR
- the result value typemapper
- the function that receives the upstream value and returns a ObservableSource
that should emit a single value to be emitted.combiner
- the bi-function that receives the original upstream value and the
single value emitted by the ObservableSource and returns a result value to be emitted to
downstream.public static <T,U,R> ObservableTransformer<T,R> mapAsync(Function<? super T,? extends ObservableSource<? extends U>> mapper, BiFunction<? super T,? super U,? extends R> combiner, int capacityHint)
Only the first item emitted by the inner ObservableSource are considered. If the inner ObservableSource is empty, no resulting item is generated for that input value.
The inner ObservableSources are consumed in order and one at a time.
T
- the input value typeU
- the intermediate value typeR
- the result value typemapper
- the function that receives the upstream value and returns a ObservableSource
that should emit a single value to be emitted.combiner
- the bi-function that receives the original upstream value and the
single value emitted by the ObservableSource and returns a result value to be emitted to
downstream.capacityHint
- the number of items expected from the upstream to be buffered while each
inner ObservableSource is executing.public static <T> ObservableTransformer<T,T> filterAsync(Function<? super T,? extends ObservableSource<Boolean>> asyncPredicate)
true
or false
value provided by a generated ObservableSource for that
input value and emits the input value if the inner ObservableSource returned true
.
Only the first item emitted by the inner ObservableSource's are considered. If the inner ObservableSource is empty, no resulting item is generated for that input value.
The inner ObservableSources are consumed in order and one at a time.
T
- the input and output value typeasyncPredicate
- the function that receives the upstream value and returns
a ObservableSource that should emit a single true to indicate the original value should pass.public static <T> ObservableTransformer<T,T> filterAsync(Function<? super T,? extends ObservableSource<Boolean>> asyncPredicate, int bufferSize)
true
or false
value provided by a generated ObservableSource for that
input value and emits the input value if the inner ObservableSource returned true
.
Only the first item emitted by the inner ObservableSource's are considered. If the inner ObservableSource is empty, no resulting item is generated for that input value.
The inner ObservableSources are consumed in order and one at a time.
T
- the input and output value typeasyncPredicate
- the function that receives the upstream value and returns
a ObservableSource that should emit a single true to indicate the original value should pass.bufferSize
- the internal buffer size and prefetch amount to buffer items from
upstream until their turn comes up