Class Observable<T>
- java.lang.Object
-
- io.reactivex.rxjava3.core.Observable<T>
-
- Type Parameters:
T
- the type of the items emitted by theObservable
- All Implemented Interfaces:
ObservableSource<T>
- Direct Known Subclasses:
AbstractObservableWithUpstream
,CompletableAndThenObservable
,CompletableToObservable
,ConnectableObservable
,GroupedObservable
,MaybeFlatMapIterableObservable
,MaybeFlatMapObservable
,MaybeFlattenStreamAsObservable
,MaybeToObservable
,ObservableAmb
,ObservableAutoConnect
,ObservableCollectWithCollector
,ObservableCombineLatest
,ObservableConcatMapMaybe
,ObservableConcatMapSingle
,ObservableCreate
,ObservableDefer
,ObservableDelaySubscriptionOther
,ObservableEmpty
,ObservableError
,ObservableFlatMapStream
,ObservableFromAction
,ObservableFromArray
,ObservableFromCallable
,ObservableFromCompletable
,ObservableFromCompletionStage
,ObservableFromFuture
,ObservableFromIterable
,ObservableFromPublisher
,ObservableFromRunnable
,ObservableFromStream
,ObservableFromSupplier
,ObservableFromUnsafeSource
,ObservableGenerate
,ObservableInterval
,ObservableIntervalRange
,ObservableJust
,ObservableMapOptional
,ObservableNever
,ObservableRange
,ObservableRangeLong
,ObservableRefCount
,ObservableReplay.MulticastReplay
,ObservableScalarXMap.ScalarXMapObservable
,ObservableSequenceEqual
,ObservableSwitchMapMaybe
,ObservableSwitchMapSingle
,ObservableTimer
,ObservableUsing
,ObservableWindowBoundarySelector.WindowBoundaryMainObserver.WindowEndObserverIntercept
,ObservableWindowSubscribeIntercept
,ObservableZip
,ObservableZipIterable
,SingleFlatMapIterableObservable
,SingleFlatMapObservable
,SingleFlattenStreamAsObservable
,SingleToObservable
,Subject
public abstract class Observable<@NonNull T> extends java.lang.Object implements ObservableSource<T>
TheObservable
class is the non-backpressured, optionally multi-valued base reactive class that offers factory methods, intermediate operators and the ability to consume synchronous and/or asynchronous reactive dataflows.Many operators in the class accept
ObservableSource
(s), the base reactive interface for such non-backpressured flows, whichObservable
itself implements as well.The
Observable
's operators, by default, run with a buffer size of 128 elements (seeFlowable.bufferSize()
), that can be overridden globally via the system parameterrx3.buffer-size
. Most operators, however, have overloads that allow setting their internal buffer size explicitly.The documentation for this class makes use of marble diagrams. The following legend explains these diagrams:
The design of this class was derived from the Reactive-Streams design and specification by removing any backpressure-related infrastructure and implementation detail, replacing the
org.reactivestreams.Subscription
withDisposable
as the primary means to dispose of a flow.The
Observable
follows the protocol
where the stream can be disposed through theonSubscribe onNext* (onError | onComplete)?
Disposable
instance provided to consumers throughObserver.onSubscribe
.Unlike the
Observable
of version 1.x,subscribe(Observer)
does not allow external disposal of a subscription and theObserver
instance is expected to expose such capability.Example:
Disposable d = Observable.just("Hello world!") .delay(1, TimeUnit.SECONDS) .subscribeWith(new DisposableObserver<String>() { @Override public void onStart() { System.out.println("Start!"); } @Override public void onNext(String t) { System.out.println(t); } @Override public void onError(Throwable t) { t.printStackTrace(); } @Override public void onComplete() { System.out.println("Done!"); } }); Thread.sleep(500); // the sequence can now be disposed via dispose() d.dispose();
- See Also:
Flowable
,DisposableObserver
-
-
Constructor Summary
Constructors Constructor Description Observable()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description @NonNull Single<java.lang.Boolean>
all(@NonNull Predicate<? super @NonNull T> predicate)
Returns aSingle
that emits aBoolean
that indicates whether all of the items emitted by the currentObservable
satisfy a condition.static <@NonNull T>
@NonNull Observable<T>amb(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
Mirrors the oneObservableSource
in anIterable
of severalObservableSource
s that first either emits an item or sends a termination notification.static <@NonNull T>
@NonNull Observable<T>ambArray(@NonNull ObservableSource<? extends @NonNull T>... sources)
Mirrors the oneObservableSource
in an array of severalObservableSource
s that first either emits an item or sends a termination notification.@NonNull Observable<T>
ambWith(@NonNull ObservableSource<? extends @NonNull T> other)
Mirrors the currentObservable
or the otherObservableSource
provided of which the first either emits an item or sends a termination notification.@NonNull Single<java.lang.Boolean>
any(@NonNull Predicate<? super @NonNull T> predicate)
Returns aSingle
that emitstrue
if any item emitted by the currentObservable
satisfies a specified condition, otherwisefalse
.T
blockingFirst()
Returns the first item emitted by the currentObservable
, or throwsNoSuchElementException
if it emits no items.T
blockingFirst(@NonNull T defaultItem)
Returns the first item emitted by the currentObservable
, or a default value if it emits no items.void
blockingForEach(@NonNull Consumer<? super @NonNull T> onNext)
Consumes the currentObservable
in a blocking fashion and invokes the givenConsumer
with each upstream item on the current thread until the upstream terminates.void
blockingForEach(@NonNull Consumer<? super @NonNull T> onNext, int capacityHint)
Consumes the currentObservable
in a blocking fashion and invokes the givenConsumer
with each upstream item on the current thread until the upstream terminates.@NonNull java.lang.Iterable<T>
blockingIterable()
Exposes the currentObservable
as anIterable
which, when iterated, subscribes to the currentObservable
and blocks until the currentObservable
emits items or terminates.@NonNull java.lang.Iterable<T>
blockingIterable(int capacityHint)
Exposes the currentObservable
as anIterable
which, when iterated, subscribes to the currentObservable
and blocks until the currentObservable
emits items or terminates.T
blockingLast()
Returns the last item emitted by the currentObservable
, or throwsNoSuchElementException
if the currentObservable
emits no items.T
blockingLast(@NonNull T defaultItem)
Returns the last item emitted by the currentObservable
, or a default value if it emits no items.@NonNull java.lang.Iterable<T>
blockingLatest()
Returns anIterable
that returns the latest item emitted by the currentObservable
, waiting if necessary for one to become available.@NonNull java.lang.Iterable<T>
blockingMostRecent(@NonNull T initialItem)
Returns anIterable
that always returns the item most recently emitted by the currentObservable
.@NonNull java.lang.Iterable<T>
blockingNext()
Returns anIterable
that blocks until the currentObservable
emits another item, then returns that item.T
blockingSingle()
If the currentObservable
completes after emitting a single item, return that item, otherwise throw aNoSuchElementException
.T
blockingSingle(@NonNull T defaultItem)
If the currentObservable
completes after emitting a single item, return that item; if it emits more than one item, throw anIllegalArgumentException
; if it emits no items, return a default value.@NonNull java.util.stream.Stream<T>
blockingStream()
Creates a sequentialStream
to consume or process the currentObservable
in a blocking manner via the JavaStream
API.@NonNull java.util.stream.Stream<T>
blockingStream(int capacityHint)
Creates a sequentialStream
to consume or process the currentObservable
in a blocking manner via the JavaStream
API.void
blockingSubscribe()
Runs the currentObservable
to a terminal event, ignoring any values and rethrowing any exception.void
blockingSubscribe(@NonNull Observer<? super @NonNull T> observer)
Subscribes to the source and calls theObserver
methods on the current thread.void
blockingSubscribe(@NonNull Consumer<? super @NonNull T> onNext)
Subscribes to the source and calls the given callbacks on the current thread.void
blockingSubscribe(@NonNull Consumer<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError)
Subscribes to the source and calls the given callbacks on the current thread.void
blockingSubscribe(@NonNull Consumer<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull Action onComplete)
Subscribes to the source and calls the given callbacks on the current thread.@NonNull Observable<@NonNull java.util.List<T>>
buffer(int count)
Returns anObservable
that emits buffers of items it collects from the currentObservable
.@NonNull Observable<@NonNull java.util.List<T>>
buffer(int count, int skip)
Returns anObservable
that emits buffers of items it collects from the currentObservable
.<@NonNull U extends java.util.Collection<? super @NonNull T>>
@NonNull Observable<U>buffer(int count, int skip, @NonNull Supplier<@NonNull U> bufferSupplier)
Returns anObservable
that emits buffers of items it collects from the currentObservable
.<@NonNull U extends java.util.Collection<? super @NonNull T>>
@NonNull Observable<U>buffer(int count, @NonNull Supplier<@NonNull U> bufferSupplier)
Returns anObservable
that emits buffers of items it collects from the currentObservable
.@NonNull Observable<@NonNull java.util.List<T>>
buffer(long timespan, long timeskip, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits buffers of items it collects from the currentObservable
.@NonNull Observable<@NonNull java.util.List<T>>
buffer(long timespan, long timeskip, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that emits buffers of items it collects from the currentObservable
.<@NonNull U extends java.util.Collection<? super @NonNull T>>
@NonNull Observable<U>buffer(long timespan, long timeskip, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, @NonNull Supplier<@NonNull U> bufferSupplier)
Returns anObservable
that emits buffers of items it collects from the currentObservable
.@NonNull Observable<@NonNull java.util.List<T>>
buffer(long timespan, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits buffers of items it collects from the currentObservable
.@NonNull Observable<@NonNull java.util.List<T>>
buffer(long timespan, @NonNull java.util.concurrent.TimeUnit unit, int count)
Returns anObservable
that emits buffers of items it collects from the currentObservable
.@NonNull Observable<@NonNull java.util.List<T>>
buffer(long timespan, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that emits buffers of items it collects from the currentObservable
.@NonNull Observable<@NonNull java.util.List<T>>
buffer(long timespan, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, int count)
Returns anObservable
that emits buffers of items it collects from the currentObservable
.<@NonNull U extends java.util.Collection<? super @NonNull T>>
@NonNull Observable<U>buffer(long timespan, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, int count, @NonNull Supplier<@NonNull U> bufferSupplier, boolean restartTimerOnMaxSize)
Returns anObservable
that emits buffers of items it collects from the currentObservable
.<@NonNull TOpening,@NonNull TClosing>
@NonNull Observable<@NonNull java.util.List<T>>buffer(@NonNull ObservableSource<? extends @NonNull TOpening> openingIndicator, @NonNull Function<? super @NonNull TOpening,? extends ObservableSource<? extends @NonNull TClosing>> closingIndicator)
Returns anObservable
that emits buffers of items it collects from the currentObservable
.<@NonNull TOpening,@NonNull TClosing,@NonNull U extends java.util.Collection<? super @NonNull T>>
@NonNull Observable<U>buffer(@NonNull ObservableSource<? extends @NonNull TOpening> openingIndicator, @NonNull Function<? super @NonNull TOpening,? extends ObservableSource<? extends @NonNull TClosing>> closingIndicator, @NonNull Supplier<@NonNull U> bufferSupplier)
Returns anObservable
that emits buffers of items it collects from the currentObservable
.<@NonNull B>
@NonNull Observable<@NonNull java.util.List<T>>buffer(@NonNull ObservableSource<@NonNull B> boundaryIndicator)
Returns anObservable
that emits non-overlapping buffered items from the currentObservable
each time the specified boundaryObservableSource
emits an item.<@NonNull B>
@NonNull Observable<@NonNull java.util.List<T>>buffer(@NonNull ObservableSource<@NonNull B> boundaryIndicator, int initialCapacity)
Returns anObservable
that emits non-overlapping buffered items from the currentObservable
each time the specified boundaryObservableSource
emits an item.<@NonNull B,@NonNull U extends java.util.Collection<? super @NonNull T>>
@NonNull Observable<U>buffer(@NonNull ObservableSource<@NonNull B> boundaryIndicator, @NonNull Supplier<@NonNull U> bufferSupplier)
Returns anObservable
that emits non-overlapping buffered items from the currentObservable
each time the specified boundaryObservableSource
emits an item.static int
bufferSize()
Returns the default 'island' size or capacity-increment hint for unbounded buffers.@NonNull Observable<T>
cache()
Returns anObservable
that subscribes to the currentObservable
lazily, caches all of its events and replays them, in the same order as received, to all the downstream observers.@NonNull Observable<T>
cacheWithInitialCapacity(int initialCapacity)
Returns anObservable
that subscribes to the currentObservable
lazily, caches all of its events and replays them, in the same order as received, to all the downstream observers.<@NonNull U>
@NonNull Observable<U>cast(@NonNull java.lang.Class<@NonNull U> clazz)
Returns anObservable
that emits the upstream items while they can be cast viaClass.cast(Object)
until the upstream terminates, or until the upstream signals an item which can't be cast, resulting in aClassCastException
to be signaled to the downstream.<@NonNull U>
@NonNull Single<U>collect(@NonNull Supplier<? extends @NonNull U> initialItemSupplier, @NonNull BiConsumer<? super @NonNull U,? super @NonNull T> collector)
Collects items emitted by the finite sourceObservable
into a single mutable data structure and returns aSingle
that emits this structure.<@NonNull R,@Nullable A>
@NonNull Single<R>collect(@NonNull java.util.stream.Collector<? super @NonNull T,@Nullable A,@NonNull R> collector)
Collects the finite upstream's values into a container via aStream
Collector
callback set and emits it as the success result as aSingle
.<@NonNull U>
@NonNull Single<U>collectInto(@NonNull U initialItem, @NonNull BiConsumer<? super @NonNull U,? super @NonNull T> collector)
Collects items emitted by the finite sourceObservable
into a single mutable data structure and returns aSingle
that emits this structure.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull T9,@NonNull R>
@NonNull Observable<R>combineLatest(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull ObservableSource<? extends @NonNull T6> source6, @NonNull ObservableSource<? extends @NonNull T7> source7, @NonNull ObservableSource<? extends @NonNull T8> source8, @NonNull ObservableSource<? extends @NonNull T9> source9, @NonNull Function9<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? super @NonNull T8,? super @NonNull T9,? extends @NonNull R> combiner)
Combines nine sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull R>
@NonNull Observable<R>combineLatest(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull ObservableSource<? extends @NonNull T6> source6, @NonNull ObservableSource<? extends @NonNull T7> source7, @NonNull ObservableSource<? extends @NonNull T8> source8, @NonNull Function8<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? super @NonNull T8,? extends @NonNull R> combiner)
Combines eight sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull R>
@NonNull Observable<R>combineLatest(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull ObservableSource<? extends @NonNull T6> source6, @NonNull ObservableSource<? extends @NonNull T7> source7, @NonNull Function7<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? extends @NonNull R> combiner)
Combines seven sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull R>
@NonNull Observable<R>combineLatest(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull ObservableSource<? extends @NonNull T6> source6, @NonNull Function6<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? extends @NonNull R> combiner)
Combines six sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull R>
@NonNull Observable<R>combineLatest(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull Function5<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? extends @NonNull R> combiner)
Combines five sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull R>
@NonNull Observable<R>combineLatest(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull Function4<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? extends @NonNull R> combiner)
Combines four sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull R>
@NonNull Observable<R>combineLatest(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull Function3<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? extends @NonNull R> combiner)
Combines three sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.static <@NonNull T1,@NonNull T2,@NonNull R>
@NonNull Observable<R>combineLatest(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> combiner)
Combines two sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from either of theObservableSource
s, where this aggregation is defined by a specified function.static <@NonNull T,@NonNull R>
@NonNull Observable<R>combineLatest(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner)
Combines a collection of sourceObservableSource
s by emitting an item that aggregates the latest values of each of the returnedObservableSource
s each time an item is received from any of the returnedObservableSource
s, where this aggregation is defined by a specified function.static <@NonNull T,@NonNull R>
@NonNull Observable<R>combineLatest(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner, int bufferSize)
Combines anIterable
of sourceObservableSource
s by emitting an item that aggregates the latest values of each of the returnedObservableSource
s each time an item is received from any of the returnedObservableSource
s, where this aggregation is defined by a specified function.static <@NonNull T,@NonNull R>
@NonNull Observable<R>combineLatestArray(@NonNull ObservableSource<? extends @NonNull T>[] sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner)
Combines an array of sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of the returnedObservableSource
s, where this aggregation is defined by a specified function.static <@NonNull T,@NonNull R>
@NonNull Observable<R>combineLatestArray(@NonNull ObservableSource<? extends @NonNull T>[] sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner, int bufferSize)
Combines an array of sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.static <@NonNull T,@NonNull R>
@NonNull Observable<R>combineLatestArrayDelayError(@NonNull ObservableSource<? extends @NonNull T>[] sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner)
Combines an array ofObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.static <@NonNull T,@NonNull R>
@NonNull Observable<R>combineLatestArrayDelayError(@NonNull ObservableSource<? extends @NonNull T>[] sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner, int bufferSize)
Combines an array ofObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function and delays any error from the sources until all sourceObservableSource
s terminate.static <@NonNull T,@NonNull R>
@NonNull Observable<R>combineLatestDelayError(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner)
Combines anIterable
ofObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function and delays any error from the sources until all sourceObservableSource
s terminate.static <@NonNull T,@NonNull R>
@NonNull Observable<R>combineLatestDelayError(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner, int bufferSize)
Combines anIterable
ofObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function and delays any error from the sources until all sourceObservableSource
s terminate.<@NonNull R>
@NonNull Observable<R>compose(@NonNull ObservableTransformer<? super @NonNull T,? extends @NonNull R> composer)
Transform the currentObservable
by applying a particularObservableTransformer
function to it.static <@NonNull T>
@NonNull Observable<T>concat(@NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
Returns anObservable
that emits the items emitted by each of theObservableSource
s emitted by theObservableSource
, one after the other, without interleaving them.static <@NonNull T>
@NonNull Observable<T>concat(@NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources, int bufferSize)
Returns anObservable
that emits the items emitted by each of theObservableSource
s emitted by the outerObservableSource
, one after the other, without interleaving them.static <@NonNull T>
@NonNull Observable<T>concat(@NonNull ObservableSource<? extends @NonNull T> source1, @NonNull ObservableSource<? extends @NonNull T> source2, @NonNull ObservableSource<? extends @NonNull T> source3)
Returns anObservable
that emits the items emitted by threeObservableSource
s, one after the other, without interleaving them.static <@NonNull T>
@NonNull Observable<T>concat(@NonNull ObservableSource<? extends @NonNull T> source1, @NonNull ObservableSource<? extends @NonNull T> source2, @NonNull ObservableSource<? extends @NonNull T> source3, @NonNull ObservableSource<? extends @NonNull T> source4)
Returns anObservable
that emits the items emitted by fourObservableSource
s, one after the other, without interleaving them.static <@NonNull T>
@NonNull Observable<T>concat(@NonNull ObservableSource<? extends @NonNull T> source1, ObservableSource<? extends @NonNull T> source2)
Returns anObservable
that emits the items emitted by twoObservableSource
s, one after the other, without interleaving them.static <@NonNull T>
@NonNull Observable<T>concat(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
Concatenates elements of eachObservableSource
provided via anIterable
sequence into a single sequence of elements without interleaving them.static <@NonNull T>
@NonNull Observable<T>concatArray(@NonNull ObservableSource<? extends @NonNull T>... sources)
Concatenates a variable number ofObservableSource
sources.static <@NonNull T>
@NonNull Observable<T>concatArrayDelayError(@NonNull ObservableSource<? extends @NonNull T>... sources)
Concatenates a variable number ofObservableSource
sources and delays errors from any of them till all terminate.static <@NonNull T>
@NonNull Observable<T>concatArrayEager(int maxConcurrency, int bufferSize, @NonNull ObservableSource<? extends @NonNull T>... sources)
Concatenates an array ofObservableSource
s eagerly into a single stream of values.static <@NonNull T>
@NonNull Observable<T>concatArrayEager(@NonNull ObservableSource<? extends @NonNull T>... sources)
Concatenates an array ofObservableSource
s eagerly into a single stream of values.static <@NonNull T>
@NonNull Observable<T>concatArrayEagerDelayError(int maxConcurrency, int bufferSize, @NonNull ObservableSource<? extends @NonNull T>... sources)
Concatenates an array ofObservableSource
s eagerly into a single stream of values and delaying any errors until all sources terminate.static <@NonNull T>
@NonNull Observable<T>concatArrayEagerDelayError(@NonNull ObservableSource<? extends @NonNull T>... sources)
Concatenates an array ofObservableSource
s eagerly into a single stream of values and delaying any errors until all sources terminate.static <@NonNull T>
@NonNull Observable<T>concatDelayError(@NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
Concatenates theObservableSource
sequence ofObservableSource
s into a singleObservable
sequence by subscribing to each innerObservableSource
, one after the other, one at a time and delays any errors till the all inner and the outerObservableSource
s terminate.static <@NonNull T>
@NonNull Observable<T>concatDelayError(@NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources, int bufferSize, boolean tillTheEnd)
Concatenates theObservableSource
sequence ofObservableSource
s into a single sequence by subscribing to each innerObservableSource
, one after the other, one at a time and delays any errors till the all inner and the outerObservableSource
s terminate.static <@NonNull T>
@NonNull Observable<T>concatDelayError(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
Concatenates theIterable
sequence ofObservableSource
s into a singleObservable
sequence by subscribing to eachObservableSource
, one after the other, one at a time and delays any errors till the all innerObservableSource
s terminate.static <@NonNull T>
@NonNull Observable<T>concatEager(@NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
Concatenates anObservableSource
sequence ofObservableSource
s eagerly into a single stream of values.static <@NonNull T>
@NonNull Observable<T>concatEager(@NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency, int bufferSize)
Concatenates anObservableSource
sequence ofObservableSource
s eagerly into a single stream of values and runs a limited number of inner sequences at once.static <@NonNull T>
@NonNull Observable<T>concatEager(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
Concatenates a sequence ofObservableSource
s eagerly into a single stream of values.static <@NonNull T>
@NonNull Observable<T>concatEager(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency, int bufferSize)
Concatenates a sequence ofObservableSource
s eagerly into a single stream of values and runs a limited number of inner sequences at once.static <@NonNull T>
@NonNull Observable<T>concatEagerDelayError(@NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
Concatenates anObservableSource
sequence ofObservableSource
s eagerly into a single stream of values, delaying errors until all the inner and the outer sequence terminate.static <@NonNull T>
@NonNull Observable<T>concatEagerDelayError(@NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency, int bufferSize)
Concatenates anObservableSource
sequence ofObservableSource
s eagerly into a single stream of values, delaying errors until all the inner and the outer sequence terminate and runs a limited number of inner sequences at once.static <@NonNull T>
@NonNull Observable<T>concatEagerDelayError(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
Concatenates a sequence ofObservableSource
s eagerly into a single stream of values, delaying errors until all the inner sequences terminate.static <@NonNull T>
@NonNull Observable<T>concatEagerDelayError(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency, int bufferSize)
Concatenates a sequence ofObservableSource
s eagerly into a single stream of values, delaying errors until all the inner sequences terminate and runs a limited number of inner sequences at once.<@NonNull R>
@NonNull Observable<R>concatMap(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper)
Returns a newObservable
that emits items resulting from applying a function that you supply to each item emitted by the currentObservable
, where that function returns anObservableSource
, and then emitting the items that result from concatenating those returnedObservableSource
s.<@NonNull R>
@NonNull Observable<R>concatMap(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, int bufferSize)
Returns a newObservable
that emits items resulting from applying a function that you supply to each item emitted by the currentObservable
, where that function returns anObservableSource
, and then emitting the items that result from concatenating those returnedObservableSource
s.<@NonNull R>
@NonNull Observable<R>concatMap(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, int bufferSize, @NonNull Scheduler scheduler)
Returns a newObservable
that emits items resulting from applying a function that you supply to each item emitted by the currentObservable
, where that function returns anObservableSource
, and then emitting the items that result from concatenating those returnedObservableSource
s.@NonNull Completable
concatMapCompletable(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps each element of the currentObservable
intoCompletableSource
s, subscribes to them one at a time in order and waits until the upstream and allCompletableSource
s complete.@NonNull Completable
concatMapCompletable(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper, int capacityHint)
Maps each element of the currentObservable
intoCompletableSource
s, subscribes to them one at a time in order and waits until the upstream and allCompletableSource
s complete.@NonNull Completable
concatMapCompletableDelayError(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps the upstream items intoCompletableSource
s and subscribes to them one after the other terminates, delaying all errors till both the currentObservable
and all innerCompletableSource
s terminate.@NonNull Completable
concatMapCompletableDelayError(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper, boolean tillTheEnd)
Maps the upstream items intoCompletableSource
s and subscribes to them one after the other terminates, optionally delaying all errors till both the currentObservable
and all innerCompletableSource
s terminate.@NonNull Completable
concatMapCompletableDelayError(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper, boolean tillTheEnd, int bufferSize)
Maps the upstream items intoCompletableSource
s and subscribes to them one after the other terminates, optionally delaying all errors till both the currentObservable
and all innerCompletableSource
s terminate.<@NonNull R>
@NonNull Observable<R>concatMapDelayError(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper)
Maps each of the items into anObservableSource
, subscribes to them one after the other, one at a time and emits their values in order while delaying any error from either this or any of the innerObservableSource
s till all of them terminate.<@NonNull R>
@NonNull Observable<R>concatMapDelayError(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, boolean tillTheEnd, int bufferSize)
Maps each of the items into anObservableSource
, subscribes to them one after the other, one at a time and emits their values in order while delaying any error from either this or any of the innerObservableSource
s till all of them terminate.<@NonNull R>
@NonNull Observable<R>concatMapDelayError(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, boolean tillTheEnd, int bufferSize, @NonNull Scheduler scheduler)
Maps each of the items into anObservableSource
, subscribes to them one after the other, one at a time and emits their values in order while delaying any error from either this or any of the innerObservableSource
s till all of them terminate.<@NonNull R>
@NonNull Observable<R>concatMapEager(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper)
Maps a sequence of values intoObservableSource
s and concatenates theseObservableSource
s eagerly into a singleObservable
sequence.<@NonNull R>
@NonNull Observable<R>concatMapEager(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, int maxConcurrency, int bufferSize)
Maps a sequence of values intoObservableSource
s and concatenates theseObservableSource
s eagerly into a singleObservable
sequence.<@NonNull R>
@NonNull Observable<R>concatMapEagerDelayError(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, boolean tillTheEnd)
Maps a sequence of values intoObservableSource
s and concatenates theseObservableSource
s eagerly into a singleObservable
sequence.<@NonNull R>
@NonNull Observable<R>concatMapEagerDelayError(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, boolean tillTheEnd, int maxConcurrency, int bufferSize)
Maps a sequence of values intoObservableSource
s and concatenates theseObservableSource
s eagerly into a singleObservable
sequence.<@NonNull U>
@NonNull Observable<U>concatMapIterable(@NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper)
Returns anObservable
that concatenate each item emitted by the currentObservable
with the values in anIterable
corresponding to that item that is generated by a selector.<@NonNull R>
@NonNull Observable<R>concatMapMaybe(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other succeeds or completes, emits their success value if available or terminates immediately if either the currentObservable
or the current innerMaybeSource
fail.<@NonNull R>
@NonNull Observable<R>concatMapMaybe(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper, int bufferSize)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other succeeds or completes, emits their success value if available or terminates immediately if either the currentObservable
or the current innerMaybeSource
fail.<@NonNull R>
@NonNull Observable<R>concatMapMaybeDelayError(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other terminates, emits their success value if available and delaying all errors till both the currentObservable
and all innerMaybeSource
s terminate.<@NonNull R>
@NonNull Observable<R>concatMapMaybeDelayError(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper, boolean tillTheEnd)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other terminates, emits their success value if available and optionally delaying all errors till both the currentObservable
and all innerMaybeSource
s terminate.<@NonNull R>
@NonNull Observable<R>concatMapMaybeDelayError(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper, boolean tillTheEnd, int bufferSize)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other terminates, emits their success value if available and optionally delaying all errors till both the currentObservable
and all innerMaybeSource
s terminate.<@NonNull R>
@NonNull Observable<R>concatMapSingle(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds, emits their success values or terminates immediately if either the currentObservable
or the current innerSingleSource
fail.<@NonNull R>
@NonNull Observable<R>concatMapSingle(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper, int bufferSize)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds, emits their success values or terminates immediately if either the currentObservable
or the current innerSingleSource
fail.<@NonNull R>
@NonNull Observable<R>concatMapSingleDelayError(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds or fails, emits their success values and delays all errors till both the currentObservable
and all innerSingleSource
s terminate.<@NonNull R>
@NonNull Observable<R>concatMapSingleDelayError(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper, boolean tillTheEnd)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds or fails, emits their success values and optionally delays all errors till both the currentObservable
and all innerSingleSource
s terminate.<@NonNull R>
@NonNull Observable<R>concatMapSingleDelayError(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper, boolean tillTheEnd, int bufferSize)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds or fails, emits their success values and optionally delays errors till both the currentObservable
and all innerSingleSource
s terminate.<@NonNull R>
@NonNull Observable<R>concatMapStream(@NonNull Function<? super @NonNull T,? extends java.util.stream.Stream<? extends @NonNull R>> mapper)
Maps each upstream item into aStream
and emits theStream
's items to the downstream in a sequential fashion.@NonNull Observable<T>
concatWith(@NonNull CompletableSource other)
Returns anObservable
that emits items from the currentObservable
and when it completes normally, the otherCompletableSource
is subscribed to and the returnedObservable
emits its terminal events.@NonNull Observable<T>
concatWith(@NonNull MaybeSource<? extends @NonNull T> other)
Returns anObservable
that emits the items from the currentObservable
followed by the success item or terminal events of the otherMaybeSource
.@NonNull Observable<T>
concatWith(@NonNull ObservableSource<? extends @NonNull T> other)
Returns anObservable
that first emits the items emitted from the currentObservable
, then items from theother
ObservableSource
without interleaving them.@NonNull Observable<T>
concatWith(@NonNull SingleSource<? extends @NonNull T> other)
Returns anObservable
that emits the items from the currentObservable
followed by the success item or error event of theother
SingleSource
.@NonNull Single<java.lang.Boolean>
contains(@NonNull java.lang.Object item)
Returns aSingle
that emits aBoolean
that indicates whether the currentObservable
emitted a specified item.@NonNull Single<java.lang.Long>
count()
Returns aSingle
that counts the total number of items emitted by the currentObservable
and emits this count as a 64-bitLong
.static <@NonNull T>
@NonNull Observable<T>create(@NonNull ObservableOnSubscribe<@NonNull T> source)
Provides an API (via a coldObservable
) that bridges the reactive world with the callback-style world.@NonNull Observable<T>
debounce(long timeout, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that mirrors the currentObservable
, except that it drops items emitted by the currentObservable
that are followed by newer items before a timeout value expires.@NonNull Observable<T>
debounce(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that mirrors the currentObservable
, except that it drops items emitted by the currentObservable
that are followed by newer items before a timeout value expires on a specifiedScheduler
.@NonNull Observable<T>
debounce(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, @NonNull Consumer<? super @NonNull T> onDropped)
Returns anObservable
that mirrors the currentObservable
, except that it drops items emitted by the currentObservable
that are followed by newer items before a timeout value expires on a specifiedScheduler
.<@NonNull U>
@NonNull Observable<T>debounce(@NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull U>> debounceIndicator)
Returns anObservable
that mirrors the currentObservable
, except that it drops items emitted by the currentObservable
that are followed by another item within a computed debounce duration denoted by an item emission or completion from a generated innerObservableSource
for that original item.@NonNull Observable<T>
defaultIfEmpty(@NonNull T defaultItem)
Returns anObservable
that emits the items emitted by the currentObservable
or a specified default item if the currentObservable
is empty.static <@NonNull T>
@NonNull Observable<T>defer(@NonNull Supplier<? extends @NonNull ObservableSource<? extends @NonNull T>> supplier)
Returns anObservable
that calls anObservableSource
factory to create anObservableSource
for each newObserver
that subscribes.@NonNull Observable<T>
delay(long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits the items emitted by the currentObservable
shifted forward in time by a specified delay.@NonNull Observable<T>
delay(long time, @NonNull java.util.concurrent.TimeUnit unit, boolean delayError)
Returns anObservable
that emits the items emitted by the currentObservable
shifted forward in time by a specified delay.@NonNull Observable<T>
delay(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that emits the items emitted by the currentObservable
shifted forward in time by a specified delay.@NonNull Observable<T>
delay(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError)
Returns anObservable
that emits the items emitted by the currentObservable
shifted forward in time by a specified delay.<@NonNull U,@NonNull V>
@NonNull Observable<T>delay(@NonNull ObservableSource<@NonNull U> subscriptionIndicator, @NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull V>> itemDelayIndicator)
Returns anObservable
that delays the subscription to and emissions from the currentObservable
viaObservableSource
s for the subscription itself and on a per-item basis.<@NonNull U>
@NonNull Observable<T>delay(@NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull U>> itemDelayIndicator)
Returns anObservable
that delays the emissions of the currentObservable
via a per-item derivedObservableSource
's item emission or termination, on a per source item basis.@NonNull Observable<T>
delaySubscription(long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that delays the subscription to the currentObservable
by a given amount of time.@NonNull Observable<T>
delaySubscription(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that delays the subscription to the currentObservable
by a given amount of time, both waiting and subscribing on a givenScheduler
.<@NonNull U>
@NonNull Observable<T>delaySubscription(@NonNull ObservableSource<@NonNull U> subscriptionIndicator)
Returns anObservable
that delays the subscription to the currentObservable
until the otherObservableSource
emits an element or completes normally.<@NonNull R>
@NonNull Observable<R>dematerialize(@NonNull Function<? super @NonNull T,Notification<@NonNull R>> selector)
Returns anObservable
that reverses the effect ofmaterialize
by transforming theNotification
objects extracted from the source items via a selector function into their respectiveObserver
signal types.@NonNull Observable<T>
distinct()
Returns anObservable
that emits all items emitted by the currentObservable
that are distinct based onObject.equals(Object)
comparison.<@NonNull K>
@NonNull Observable<T>distinct(@NonNull Function<? super @NonNull T,@NonNull K> keySelector)
Returns anObservable
that emits all items emitted by the currentObservable
that are distinct according to a key selector function and based onObject.equals(Object)
comparison of the objects returned by the key selector function.<@NonNull K>
@NonNull Observable<T>distinct(@NonNull Function<? super @NonNull T,@NonNull K> keySelector, @NonNull Supplier<? extends java.util.Collection<? super @NonNull K>> collectionSupplier)
Returns anObservable
that emits all items emitted by the currentObservable
that are distinct according to a key selector function and based onObject.equals(Object)
comparison of the objects returned by the key selector function.@NonNull Observable<T>
distinctUntilChanged()
Returns anObservable
that emits all items emitted by the currentObservable
that are distinct from their immediate predecessors based onObject.equals(Object)
comparison.@NonNull Observable<T>
distinctUntilChanged(@NonNull BiPredicate<? super @NonNull T,? super @NonNull T> comparer)
Returns anObservable
that emits all items emitted by the currentObservable
that are distinct from their immediate predecessors when compared with each other via the provided comparator function.<@NonNull K>
@NonNull Observable<T>distinctUntilChanged(@NonNull Function<? super @NonNull T,@NonNull K> keySelector)
Returns anObservable
that emits all items emitted by the currentObservable
that are distinct from their immediate predecessors, according to a key selector function and based onObject.equals(Object)
comparison of those objects returned by the key selector function.@NonNull Observable<T>
doAfterNext(@NonNull Consumer<? super @NonNull T> onAfterNext)
Calls the specifiedConsumer
with the current item after this item has been emitted to the downstream.@NonNull Observable<T>
doAfterTerminate(@NonNull Action onAfterTerminate)
@NonNull Observable<T>
doFinally(@NonNull Action onFinally)
Calls the specified action after the currentObservable
signalsonError
oronCompleted
or gets disposed by the downstream.@NonNull Observable<T>
doOnComplete(@NonNull Action onComplete)
@NonNull Observable<T>
doOnDispose(@NonNull Action onDispose)
Calls the given sharedAction
if the downstream disposes the sequence.@NonNull Observable<T>
doOnEach(@NonNull Observer<? super @NonNull T> observer)
Returns anObservable
that forwards the items and terminal events of the currentObservable
to itsObserver
s and to the given sharedObserver
instance.@NonNull Observable<T>
doOnEach(@NonNull Consumer<? super Notification<@NonNull T>> onNotification)
Returns anObservable
that invokes aConsumer
with the appropriateNotification
object when the currentObservable
signals an item or terminates.private @NonNull Observable<T>
doOnEach(@NonNull Consumer<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull Action onComplete, @NonNull Action onAfterTerminate)
Calls the appropriateonXXX
consumer (shared between allObserver
s) whenever a signal with the same type passes through, before forwarding them to the downstream.@NonNull Observable<T>
doOnError(@NonNull Consumer<? super java.lang.Throwable> onError)
Calls the givenConsumer
with the errorThrowable
if the currentObservable
failed before forwarding it to the downstream.@NonNull Observable<T>
doOnLifecycle(@NonNull Consumer<? super Disposable> onSubscribe, @NonNull Action onDispose)
Calls the appropriateonXXX
method (shared between allObserver
s) for the lifecycle events of the sequence (subscription, disposal).@NonNull Observable<T>
doOnNext(@NonNull Consumer<? super @NonNull T> onNext)
Calls the givenConsumer
with the value emitted by the currentObservable
before forwarding it to the downstream.@NonNull Observable<T>
doOnSubscribe(@NonNull Consumer<? super Disposable> onSubscribe)
@NonNull Observable<T>
doOnTerminate(@NonNull Action onTerminate)
Returns anObservable
so that it invokes an action when the currentObservable
callsonComplete
oronError
.@NonNull Maybe<T>
elementAt(long index)
Returns aMaybe
that emits the single item at a specified index in a sequence of emissions from the currentObservable
or completes if the currentObservable
signals fewer elements than index.@NonNull Single<T>
elementAt(long index, @NonNull T defaultItem)
Returns aSingle
that emits the item found at a specified index in a sequence of emissions from the currentObservable
, or a default item if that index is out of range.@NonNull Single<T>
elementAtOrError(long index)
Returns aSingle
that emits the item found at a specified index in a sequence of emissions from the currentObservable
or signals aNoSuchElementException
if the currentObservable
signals fewer elements than index.static <@NonNull T>
@NonNull Observable<T>empty()
Returns anObservable
that emits no items to theObserver
and immediately invokes itsonComplete
method.static <@NonNull T>
@NonNull Observable<T>error(@NonNull Supplier<? extends @NonNull java.lang.Throwable> supplier)
static <@NonNull T>
@NonNull Observable<T>error(@NonNull java.lang.Throwable throwable)
@NonNull Observable<T>
filter(@NonNull Predicate<? super @NonNull T> predicate)
Filters items emitted by the currentObservable
by only emitting those that satisfy a specifiedPredicate
.@NonNull Single<T>
first(@NonNull T defaultItem)
Returns aSingle
that emits only the very first item emitted by the currentObservable
, or a default item if the currentObservable
completes without emitting any items.@NonNull Maybe<T>
firstElement()
Returns aMaybe
that emits only the very first item emitted by the currentObservable
, or completes if the currentObservable
is empty.@NonNull Single<T>
firstOrError()
Returns aSingle
that emits only the very first item emitted by the currentObservable
or signals aNoSuchElementException
if the currentObservable
is empty.@NonNull java.util.concurrent.CompletionStage<T>
firstOrErrorStage()
Signals the first upstream item or aNoSuchElementException
if the upstream is empty via aCompletionStage
.@NonNull java.util.concurrent.CompletionStage<T>
firstStage(@NonNull T defaultItem)
Signals the first upstream item (or the default item if the upstream is empty) via aCompletionStage
.<@NonNull R>
@NonNull Observable<R>flatMap(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper)
Returns anObservable
that emits items based on applying a function that you supply to each item emitted by the currentObservable
, where that function returns anObservableSource
, and then merging those returnedObservableSource
s and emitting the results of this merger.<@NonNull R>
@NonNull Observable<R>flatMap(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, boolean delayErrors)
Returns anObservable
that emits items based on applying a function that you supply to each item emitted by the currentObservable
, where that function returns anObservableSource
, and then merging those returnedObservableSource
s and emitting the results of this merger.<@NonNull R>
@NonNull Observable<R>flatMap(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, boolean delayErrors, int maxConcurrency)
Returns anObservable
that emits items based on applying a function that you supply to each item emitted by the currentObservable
, where that function returns anObservableSource
, and then merging those returnedObservableSource
s and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to theseObservableSource
s.<@NonNull R>
@NonNull Observable<R>flatMap(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, boolean delayErrors, int maxConcurrency, int bufferSize)
Returns anObservable
that emits items based on applying a function that you supply to each item emitted by the currentObservable
, where that function returns anObservableSource
, and then merging those returnedObservableSource
s and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to theseObservableSource
s.<@NonNull R>
@NonNull Observable<R>flatMap(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, int maxConcurrency)
Returns anObservable
that emits items based on applying a function that you supply to each item emitted by the currentObservable
, where that function returns anObservableSource
, and then merging those returnedObservableSource
s and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to theseObservableSource
s.<@NonNull R>
@NonNull Observable<R>flatMap(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> onNextMapper, @NonNull Function<? super java.lang.Throwable,? extends ObservableSource<? extends @NonNull R>> onErrorMapper, @NonNull Supplier<? extends ObservableSource<? extends @NonNull R>> onCompleteSupplier)
Returns anObservable
that applies a function to each item emitted or notification raised by the currentObservable
and then flattens theObservableSource
s returned from these functions and emits the resulting items.<@NonNull R>
@NonNull Observable<R>flatMap(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> onNextMapper, @NonNull Function<java.lang.Throwable,? extends ObservableSource<? extends @NonNull R>> onErrorMapper, @NonNull Supplier<? extends ObservableSource<? extends @NonNull R>> onCompleteSupplier, int maxConcurrency)
Returns anObservable
that applies a function to each item emitted or notification raised by the currentObservable
and then flattens theObservableSource
s returned from these functions and emits the resulting items, while limiting the maximum number of concurrent subscriptions to theseObservableSource
s.<@NonNull U,@NonNull R>
@NonNull Observable<R>flatMap(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull U>> mapper, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner)
Returns anObservable
that emits the results of a specified function to the pair of values emitted by the currentObservable
and the mapped innerObservableSource
.<@NonNull U,@NonNull R>
@NonNull Observable<R>flatMap(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull U>> mapper, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner, boolean delayErrors)
Returns anObservable
that emits the results of a specified function to the pair of values emitted by the currentObservable
and the mapped innerObservableSource
.<@NonNull U,@NonNull R>
@NonNull Observable<R>flatMap(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull U>> mapper, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner, boolean delayErrors, int maxConcurrency)
Returns anObservable
that emits the results of a specified function to the pair of values emitted by the currentObservable
and the mapped innerObservableSource
, while limiting the maximum number of concurrent subscriptions to theseObservableSource
s.<@NonNull U,@NonNull R>
@NonNull Observable<R>flatMap(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull U>> mapper, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner, boolean delayErrors, int maxConcurrency, int bufferSize)
Returns anObservable
that emits the results of a specified function to the pair of values emitted by the currentObservable
and the mapped innerObservableSource
, while limiting the maximum number of concurrent subscriptions to theseObservableSource
s.<@NonNull U,@NonNull R>
@NonNull Observable<R>flatMap(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull U>> mapper, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner, int maxConcurrency)
Returns anObservable
that emits the results of a specified function to the pair of values emitted by the currentObservable
and the mapped innerObservableSource
, while limiting the maximum number of concurrent subscriptions to theseObservableSource
s.@NonNull Completable
flatMapCompletable(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps each element of the currentObservable
intoCompletableSource
s, subscribes to them and waits until the upstream and allCompletableSource
s complete.@NonNull Completable
flatMapCompletable(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper, boolean delayErrors)
Maps each element of the currentObservable
intoCompletableSource
s, subscribes to them and waits until the upstream and allCompletableSource
s complete, optionally delaying all errors.<@NonNull U>
@NonNull Observable<U>flatMapIterable(@NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper)
MergesIterable
s generated by a mapperFunction
for each individual item emitted by the currentObservable
into a singleObservable
sequence.<@NonNull U,@NonNull V>
@NonNull Observable<V>flatMapIterable(@NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull V> combiner)
MergesIterable
s generated by a mapperFunction
for each individual item emitted by the currentObservable
into a singleObservable
sequence where the resulting items will be the combination of the original item and each inner item of the respectiveIterable
as returned by theresultSelector
BiFunction
.<@NonNull R>
@NonNull Observable<R>flatMapMaybe(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps each element of the currentObservable
intoMaybeSource
s, subscribes to all of them and merges theironSuccess
values, in no particular order, into a singleObservable
sequence.<@NonNull R>
@NonNull Observable<R>flatMapMaybe(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper, boolean delayErrors)
Maps each element of the currentObservable
intoMaybeSource
s, subscribes to them and merges theironSuccess
values, in no particular order, into a singleObservable
sequence, optionally delaying all errors.<@NonNull R>
@NonNull Observable<R>flatMapSingle(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Maps each element of the currentObservable
intoSingleSource
s, subscribes to all of them and merges theironSuccess
values, in no particular order, into a singleObservable
sequence.<@NonNull R>
@NonNull Observable<R>flatMapSingle(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper, boolean delayErrors)
Maps each element of the currentObservable
intoSingleSource
s, subscribes to them and merges theironSuccess
values, in no particular order, into a singleObservable
sequence, optionally delaying all errors.<@NonNull R>
@NonNull Observable<R>flatMapStream(@NonNull Function<? super @NonNull T,? extends java.util.stream.Stream<? extends @NonNull R>> mapper)
Maps each upstream item into aStream
and emits theStream
's items to the downstream in a sequential fashion.@NonNull Disposable
forEach(@NonNull Consumer<? super @NonNull T> onNext)
Subscribes to theObservableSource
and calls aConsumer
for each item of the currentObservable
on its emission thread.@NonNull Disposable
forEachWhile(@NonNull Predicate<? super @NonNull T> onNext)
Subscribes to theObservableSource
and calls aPredicate
for each item of the currentObservable
, on its emission thread, until the predicate returnsfalse
.@NonNull Disposable
forEachWhile(@NonNull Predicate<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError)
Subscribes to theObservableSource
and calls aPredicate
for each item or aConsumer
with the error of the currentObservable
, on their original emission threads, until the predicate returnsfalse
.@NonNull Disposable
forEachWhile(@NonNull Predicate<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull Action onComplete)
Subscribes to theObservableSource
and calls aPredicate
for each item, aConsumer
with the error or anAction
upon completion of the currentObservable
, on their original emission threads, until the predicate returnsfalse
.static <@NonNull T>
@NonNull Observable<T>fromAction(@NonNull Action action)
static <@NonNull T>
@NonNull Observable<T>fromArray(@NonNull T... items)
Converts an array into anObservableSource
that emits the items in the array.static <@NonNull T>
@NonNull Observable<T>fromCallable(@NonNull java.util.concurrent.Callable<? extends @NonNull T> callable)
Returns anObservable
that, when an observer subscribes to it, invokes a function you specify and then emits the value returned from that function.static <@NonNull T>
@NonNull Observable<T>fromCompletable(@NonNull CompletableSource completableSource)
Wraps aCompletableSource
into anObservable
.static <@NonNull T>
@NonNull Observable<@NonNull T>fromCompletionStage(@NonNull java.util.concurrent.CompletionStage<@NonNull T> stage)
Signals the completion value or error of the given (hot)CompletionStage
-based asynchronous calculation.static <@NonNull T>
@NonNull Observable<T>fromFuture(@NonNull java.util.concurrent.Future<? extends @NonNull T> future)
Converts aFuture
into anObservable
.static <@NonNull T>
@NonNull Observable<T>fromFuture(@NonNull java.util.concurrent.Future<? extends @NonNull T> future, long timeout, @NonNull java.util.concurrent.TimeUnit unit)
Converts aFuture
into anObservable
, with a timeout on theFuture
.static <@NonNull T>
@NonNull Observable<T>fromIterable(@NonNull java.lang.Iterable<? extends @NonNull T> source)
Converts anIterable
sequence into anObservable
that emits the items in the sequence.static <@NonNull T>
@NonNull Observable<T>fromMaybe(@NonNull MaybeSource<@NonNull T> maybe)
Returns anObservable
instance that when subscribed to, subscribes to theMaybeSource
instance and emitsonSuccess
as a single item or forwards anyonComplete
oronError
signal.static <@NonNull T>
@NonNull Observable<@NonNull T>fromOptional(@NonNull java.util.Optional<@NonNull T> optional)
Converts the existing value of the provided optional into ajust(Object)
or an empty optional into anempty()
Observable
instance.static <@NonNull T>
@NonNull Observable<T>fromPublisher(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> publisher)
Converts an arbitrary Reactive StreamsPublisher
into anObservable
.static <@NonNull T>
@NonNull Observable<T>fromRunnable(@NonNull java.lang.Runnable run)
Returns anObservable
instance that runs the givenRunnable
for eachObserver
and emits either its unchecked exception or simply completes.static <@NonNull T>
@NonNull Observable<T>fromSingle(@NonNull SingleSource<@NonNull T> source)
Returns anObservable
instance that when subscribed to, subscribes to theSingleSource
instance and emitsonSuccess
as a single item or forwards theonError
signal.static <@NonNull T>
@NonNull Observable<@NonNull T>fromStream(@NonNull java.util.stream.Stream<@NonNull T> stream)
Converts aStream
into a finiteObservable
and emits its items in the sequence.static <@NonNull T>
@NonNull Observable<T>fromSupplier(@NonNull Supplier<? extends @NonNull T> supplier)
Returns anObservable
that, when an observer subscribes to it, invokes a supplier function you specify and then emits the value returned from that function.static <@NonNull T>
@NonNull Observable<T>generate(@NonNull Consumer<Emitter<@NonNull T>> generator)
Returns a cold, synchronous and stateless generator of values.static <@NonNull T,@NonNull S>
@NonNull Observable<T>generate(@NonNull Supplier<@NonNull S> initialState, @NonNull BiConsumer<@NonNull S,Emitter<@NonNull T>> generator)
Returns a cold, synchronous and stateful generator of values.static <@NonNull T,@NonNull S>
@NonNull Observable<T>generate(@NonNull Supplier<@NonNull S> initialState, @NonNull BiConsumer<@NonNull S,Emitter<@NonNull T>> generator, @NonNull Consumer<? super @NonNull S> disposeState)
Returns a cold, synchronous and stateful generator of values.static <@NonNull T,@NonNull S>
@NonNull Observable<T>generate(@NonNull Supplier<@NonNull S> initialState, @NonNull BiFunction<@NonNull S,Emitter<@NonNull T>,@NonNull S> generator)
Returns a cold, synchronous and stateful generator of values.static <@NonNull T,@NonNull S>
@NonNull Observable<T>generate(@NonNull Supplier<@NonNull S> initialState, @NonNull BiFunction<@NonNull S,Emitter<@NonNull T>,@NonNull S> generator, @NonNull Consumer<? super @NonNull S> disposeState)
Returns a cold, synchronous and stateful generator of values.<@NonNull K>
@NonNull Observable<GroupedObservable<K,T>>groupBy(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector)
Groups the items emitted by the currentObservable
according to a specified criterion, and emits these grouped items asGroupedObservable
s.<@NonNull K>
@NonNull Observable<GroupedObservable<K,T>>groupBy(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, boolean delayError)
Groups the items emitted by the currentObservable
according to a specified criterion, and emits these grouped items asGroupedObservable
s.<@NonNull K,@NonNull V>
@NonNull Observable<GroupedObservable<K,V>>groupBy(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector, boolean delayError)
Groups the items emitted by the currentObservable
according to a specified criterion, and emits these grouped items asGroupedObservable
s.<@NonNull K,@NonNull V>
@NonNull Observable<GroupedObservable<K,V>>groupBy(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector, boolean delayError, int bufferSize)
Groups the items emitted by the currentObservable
according to a specified criterion, and emits these grouped items asGroupedObservable
s.<@NonNull K,@NonNull V>
@NonNull Observable<GroupedObservable<K,V>>groupBy(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, Function<? super @NonNull T,? extends @NonNull V> valueSelector)
Groups the items emitted by the currentObservable
according to a specified criterion, and emits these grouped items asGroupedObservable
s.<@NonNull TRight,@NonNull TLeftEnd,@NonNull TRightEnd,@NonNull R>
@NonNull Observable<R>groupJoin(@NonNull ObservableSource<? extends @NonNull TRight> other, @NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull TLeftEnd>> leftEnd, @NonNull Function<? super @NonNull TRight,? extends ObservableSource<@NonNull TRightEnd>> rightEnd, @NonNull BiFunction<? super @NonNull T,? super Observable<@NonNull TRight>,? extends @NonNull R> resultSelector)
Returns anObservable
that correlates twoObservableSource
s when they overlap in time and groups the results.@NonNull Observable<T>
hide()
Hides the identity of the currentObservable
and itsDisposable
.@NonNull Completable
ignoreElements()
Ignores all items emitted by the currentObservable
and only callsonComplete
oronError
.static @NonNull Observable<java.lang.Long>
interval(long initialDelay, long period, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits a0L
after theinitialDelay
and ever increasing numbers after eachperiod
of time thereafter.static @NonNull Observable<java.lang.Long>
interval(long initialDelay, long period, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that emits a0L
after theinitialDelay
and ever increasing numbers after eachperiod
of time thereafter, on a specifiedScheduler
.static @NonNull Observable<java.lang.Long>
interval(long period, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits a sequential number every specified interval of time.static @NonNull Observable<java.lang.Long>
interval(long period, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that emits a sequential number every specified interval of time, on a specifiedScheduler
.static @NonNull Observable<java.lang.Long>
intervalRange(long start, long count, long initialDelay, long period, @NonNull java.util.concurrent.TimeUnit unit)
Signals a range of long values, the first after some initial delay and the rest periodically after.static @NonNull Observable<java.lang.Long>
intervalRange(long start, long count, long initialDelay, long period, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Signals a range of long values, the first after some initial delay and the rest periodically after.@NonNull Single<java.lang.Boolean>
isEmpty()
<@NonNull TRight,@NonNull TLeftEnd,@NonNull TRightEnd,@NonNull R>
@NonNull Observable<R>join(@NonNull ObservableSource<? extends @NonNull TRight> other, @NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull TLeftEnd>> leftEnd, @NonNull Function<? super @NonNull TRight,? extends ObservableSource<@NonNull TRightEnd>> rightEnd, @NonNull BiFunction<? super @NonNull T,? super @NonNull TRight,? extends @NonNull R> resultSelector)
Correlates the items emitted by twoObservableSource
s based on overlapping durations.static <@NonNull T>
@NonNull Observable<T>just(@NonNull T item)
Returns anObservable
that signals the given (constant reference) item and then completes.static <@NonNull T>
@NonNull Observable<T>just(@NonNull T item1, @NonNull T item2)
Converts two items into anObservable
that emits those items.static <@NonNull T>
@NonNull Observable<T>just(@NonNull T item1, @NonNull T item2, @NonNull T item3)
Converts three items into anObservable
that emits those items.static <@NonNull T>
@NonNull Observable<T>just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4)
Converts four items into anObservable
that emits those items.static <@NonNull T>
@NonNull Observable<T>just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5)
Converts five items into anObservable
that emits those items.static <@NonNull T>
@NonNull Observable<T>just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6)
Converts six items into anObservable
that emits those items.static <@NonNull T>
@NonNull Observable<T>just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6, @NonNull T item7)
Converts seven items into anObservable
that emits those items.static <@NonNull T>
@NonNull Observable<T>just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6, @NonNull T item7, @NonNull T item8)
Converts eight items into anObservable
that emits those items.static <@NonNull T>
@NonNull Observable<T>just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6, @NonNull T item7, @NonNull T item8, @NonNull T item9)
Converts nine items into anObservable
that emits those items.static <@NonNull T>
@NonNull Observable<T>just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6, @NonNull T item7, @NonNull T item8, @NonNull T item9, @NonNull T item10)
Converts ten items into anObservable
that emits those items.@NonNull Single<T>
last(@NonNull T defaultItem)
Returns aSingle
that emits only the last item emitted by the currentObservable
, or a default item if the currentObservable
completes without emitting any items.@NonNull Maybe<T>
lastElement()
Returns aMaybe
that emits the last item emitted by the currentObservable
or completes if the currentObservable
is empty.@NonNull Single<T>
lastOrError()
Returns aSingle
that emits only the last item emitted by the currentObservable
or signals aNoSuchElementException
if the currentObservable
is empty.@NonNull java.util.concurrent.CompletionStage<T>
lastOrErrorStage()
Signals the last upstream item or aNoSuchElementException
if the upstream is empty via aCompletionStage
.@NonNull java.util.concurrent.CompletionStage<T>
lastStage(@NonNull T defaultItem)
Signals the last upstream item (or the default item if the upstream is empty) via aCompletionStage
.<@NonNull R>
@NonNull Observable<R>lift(@NonNull ObservableOperator<? extends @NonNull R,? super @NonNull T> lifter)
This method requires advanced knowledge about building operators, please consider other standard composition methods first; Returns anObservable
which, when subscribed to, invokes theapply(Observer)
method of the providedObservableOperator
for each individual downstreamObserver
and allows the insertion of a custom operator by accessing the downstream'sObserver
during this subscription phase and providing a newObserver
, containing the custom operator's intended business logic, that will be used in the subscription process going further upstream.<@NonNull R>
@NonNull Observable<R>map(@NonNull Function<? super @NonNull T,? extends @NonNull R> mapper)
Returns anObservable
that applies a specified function to each item emitted by the currentObservable
and emits the results of these function applications.<@NonNull R>
@NonNull Observable<R>mapOptional(@NonNull Function<? super @NonNull T,@NonNull java.util.Optional<? extends @NonNull R>> mapper)
Maps each upstream value into anOptional
and emits the contained item if not empty.@NonNull Observable<Notification<T>>
materialize()
Returns anObservable
that represents all of the emissions and notifications from the currentObservable
into emissions marked with their original types withinNotification
objects.static <@NonNull T>
@NonNull Observable<T>merge(@NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
Flattens anObservableSource
that emitsObservableSource
s into a singleObservable
that emits the items emitted by thoseObservableSource
s, without any transformation.static <@NonNull T>
@NonNull Observable<T>merge(@NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency)
Flattens anObservableSource
that emitsObservableSource
s into a singleObservable
that emits the items emitted by thoseObservableSource
s, without any transformation, while limiting the maximum number of concurrent subscriptions to theseObservableSource
s.static <@NonNull T>
@NonNull Observable<T>merge(@NonNull ObservableSource<? extends @NonNull T> source1, @NonNull ObservableSource<? extends @NonNull T> source2)
Flattens twoObservableSource
s into a singleObservable
, without any transformation.static <@NonNull T>
@NonNull Observable<T>merge(@NonNull ObservableSource<? extends @NonNull T> source1, @NonNull ObservableSource<? extends @NonNull T> source2, @NonNull ObservableSource<? extends @NonNull T> source3)
Flattens threeObservableSource
s into a singleObservable
, without any transformation.static <@NonNull T>
@NonNull Observable<T>merge(@NonNull ObservableSource<? extends @NonNull T> source1, @NonNull ObservableSource<? extends @NonNull T> source2, @NonNull ObservableSource<? extends @NonNull T> source3, @NonNull ObservableSource<? extends @NonNull T> source4)
Flattens fourObservableSource
s into a singleObservable
, without any transformation.static <@NonNull T>
@NonNull Observable<T>merge(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
static <@NonNull T>
@NonNull Observable<T>merge(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency)
Flattens anIterable
ofObservableSource
s into oneObservable
, without any transformation, while limiting the number of concurrent subscriptions to theseObservableSource
s.static <@NonNull T>
@NonNull Observable<T>merge(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency, int bufferSize)
Flattens anIterable
ofObservableSource
s into oneObservable
, without any transformation, while limiting the number of concurrent subscriptions to theseObservableSource
s.static <@NonNull T>
@NonNull Observable<T>mergeArray(int maxConcurrency, int bufferSize, @NonNull ObservableSource<? extends @NonNull T>... sources)
Flattens an array ofObservableSource
s into oneObservable
, without any transformation, while limiting the number of concurrent subscriptions to theseObservableSource
s.static <@NonNull T>
@NonNull Observable<T>mergeArray(@NonNull ObservableSource<? extends @NonNull T>... sources)
Flattens an array ofObservableSource
s into oneObservable
, without any transformation.static <@NonNull T>
@NonNull Observable<T>mergeArrayDelayError(int maxConcurrency, int bufferSize, @NonNull ObservableSource<? extends @NonNull T>... sources)
Flattens an array ofObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from each of theObservableSource
s without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to theseObservableSource
s.static <@NonNull T>
@NonNull Observable<T>mergeArrayDelayError(@NonNull ObservableSource<? extends @NonNull T>... sources)
Flattens an array ofObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from each of theObservableSource
s without being interrupted by an error notification from one of them.static <@NonNull T>
@NonNull Observable<T>mergeDelayError(@NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
Flattens anObservableSource
that emitsObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from all of the emittedObservableSource
s without being interrupted by an error notification from one of them.static <@NonNull T>
@NonNull Observable<T>mergeDelayError(@NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency)
Flattens anObservableSource
that emitsObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from all of the emittedObservableSource
s without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to theseObservableSource
s.static <@NonNull T>
@NonNull Observable<T>mergeDelayError(@NonNull ObservableSource<? extends @NonNull T> source1, @NonNull ObservableSource<? extends @NonNull T> source2)
Flattens twoObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from each of theObservableSource
s without being interrupted by an error notification from one of them.static <@NonNull T>
@NonNull Observable<T>mergeDelayError(@NonNull ObservableSource<? extends @NonNull T> source1, @NonNull ObservableSource<? extends @NonNull T> source2, @NonNull ObservableSource<? extends @NonNull T> source3)
Flattens threeObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from all of theObservableSource
s without being interrupted by an error notification from one of them.static <@NonNull T>
@NonNull Observable<T>mergeDelayError(@NonNull ObservableSource<? extends @NonNull T> source1, @NonNull ObservableSource<? extends @NonNull T> source2, @NonNull ObservableSource<? extends @NonNull T> source3, @NonNull ObservableSource<? extends @NonNull T> source4)
Flattens fourObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from all of theObservableSource
s without being interrupted by an error notification from one of them.static <@NonNull T>
@NonNull Observable<T>mergeDelayError(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
Flattens anIterable
ofObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from each of the returnedObservableSource
s without being interrupted by an error notification from one of them.static <@NonNull T>
@NonNull Observable<T>mergeDelayError(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency)
Flattens anIterable
ofObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from each of the returnedObservableSource
s without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to theseObservableSource
s.static <@NonNull T>
@NonNull Observable<T>mergeDelayError(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency, int bufferSize)
Flattens anIterable
ofObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from each of the returnedObservableSource
s without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to theseObservableSource
s.@NonNull Observable<T>
mergeWith(@NonNull CompletableSource other)
Relays the items of the currentObservable
and completes only when the otherCompletableSource
completes as well.@NonNull Observable<T>
mergeWith(@NonNull MaybeSource<? extends @NonNull T> other)
Merges the sequence of items of the currentObservable
with the success value of the otherMaybeSource
or waits both to complete normally if theMaybeSource
is empty.@NonNull Observable<T>
mergeWith(@NonNull ObservableSource<? extends @NonNull T> other)
Flattens the currentObservable
and anotherObservableSource
into a singleObservable
sequence, without any transformation.@NonNull Observable<T>
mergeWith(@NonNull SingleSource<? extends @NonNull T> other)
Merges the sequence of items of the currentObservable
with the success value of the otherSingleSource
.static <@NonNull T>
@NonNull Observable<T>never()
Returns anObservable
that never sends any items or notifications to anObserver
.@NonNull Observable<T>
observeOn(@NonNull Scheduler scheduler)
Returns anObservable
to perform the currentObservable
's emissions and notifications on a specifiedScheduler
, asynchronously with an unbounded buffer withFlowable.bufferSize()
"island size".@NonNull Observable<T>
observeOn(@NonNull Scheduler scheduler, boolean delayError)
Returns anObservable
to perform the currentObservable
's emissions and notifications on a specifiedScheduler
, asynchronously with an unbounded buffer withFlowable.bufferSize()
"island size" and optionally delaysonError
notifications.@NonNull Observable<T>
observeOn(@NonNull Scheduler scheduler, boolean delayError, int bufferSize)
Returns anObservable
to perform the currentObservable
's emissions and notifications on a specifiedScheduler
, asynchronously with an unbounded buffer of configurable "island size" and optionally delaysonError
notifications.<@NonNull U>
@NonNull Observable<U>ofType(@NonNull java.lang.Class<@NonNull U> clazz)
Filters the items emitted by the currentObservable
, only emitting those of the specified type.@NonNull Observable<T>
onErrorComplete()
Returns anObservable
instance that if the currentObservable
emits an error, it will emit anonComplete
and swallow the throwable.@NonNull Observable<T>
onErrorComplete(@NonNull Predicate<? super java.lang.Throwable> predicate)
Returns anObservable
instance that if the currentObservable
emits an error and the predicate returnstrue
, it will emit anonComplete
and swallow the throwable.@NonNull Observable<T>
onErrorResumeNext(@NonNull Function<? super java.lang.Throwable,? extends ObservableSource<? extends @NonNull T>> fallbackSupplier)
Resumes the flow with anObservableSource
returned for the failureThrowable
of the currentObservable
by a function instead of signaling the error viaonError
.@NonNull Observable<T>
onErrorResumeWith(@NonNull ObservableSource<? extends @NonNull T> fallback)
Resumes the flow with the givenObservableSource
when the currentObservable
fails instead of signaling the error viaonError
.@NonNull Observable<T>
onErrorReturn(@NonNull Function<? super java.lang.Throwable,? extends @NonNull T> itemSupplier)
Ends the flow with a last item returned by a function for theThrowable
error signaled by the currentObservable
instead of signaling the error viaonError
.@NonNull Observable<T>
onErrorReturnItem(@NonNull T item)
Ends the flow with the given last item when the currentObservable
fails instead of signaling the error viaonError
.@NonNull Observable<T>
onTerminateDetach()
Nulls out references to the upstream producer and downstreamObserver
if the sequence is terminated or downstream callsdispose()
.@NonNull ConnectableObservable<T>
publish()
Returns aConnectableObservable
, which is a variety ofObservableSource
that waits until itsconnect
method is called before it begins emitting items to thoseObserver
s that have subscribed to it.<@NonNull R>
@NonNull Observable<R>publish(@NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector)
Returns anObservable
that emits the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
sequence.static @NonNull Observable<java.lang.Integer>
range(int start, int count)
Returns anObservable
that emits a sequence ofInteger
s within a specified range.static @NonNull Observable<java.lang.Long>
rangeLong(long start, long count)
Returns anObservable
that emits a sequence ofLong
s within a specified range.@NonNull Maybe<T>
reduce(@NonNull BiFunction<@NonNull T,@NonNull T,@NonNull T> reducer)
Returns aMaybe
that applies a specified accumulator function to the first item emitted by the currentObservable
, then feeds the result of that function along with the second item emitted by the currentObservable
into the same function, and so on until all items have been emitted by the current and finiteObservable
, and emits the final result from the final call to your function as its sole item.<@NonNull R>
@NonNull Single<R>reduce(@NonNull R seed, @NonNull BiFunction<@NonNull R,? super @NonNull T,@NonNull R> reducer)
Returns aSingle
that applies a specified accumulator function to the first item emitted by the currentObservable
and a specified seed value, then feeds the result of that function along with the second item emitted by the currentObservable
into the same function, and so on until all items have been emitted by the current and finiteObservable
, emitting the final result from the final call to your function as its sole item.<@NonNull R>
@NonNull Single<R>reduceWith(@NonNull Supplier<@NonNull R> seedSupplier, @NonNull BiFunction<@NonNull R,? super @NonNull T,@NonNull R> reducer)
Returns aSingle
that applies a specified accumulator function to the first item emitted by the currentObservable
and a seed value derived from calling a specifiedseedSupplier
, then feeds the result of that function along with the second item emitted by the currentObservable
into the same function, and so on until all items have been emitted by the current and finiteObservable
, emitting the final result from the final call to your function as its sole item.@NonNull Observable<T>
repeat()
Returns anObservable
that repeats the sequence of items emitted by the currentObservable
indefinitely.@NonNull Observable<T>
repeat(long times)
Returns anObservable
that repeats the sequence of items emitted by the currentObservable
at mostcount
times.@NonNull Observable<T>
repeatUntil(@NonNull BooleanSupplier stop)
Returns anObservable
that repeats the sequence of items emitted by the currentObservable
until the provided stop function returnstrue
.@NonNull Observable<T>
repeatWhen(@NonNull Function<? super Observable<java.lang.Object>,? extends ObservableSource<?>> handler)
Returns anObservable
that emits the same values as the currentObservable
with the exception of anonComplete
.@NonNull ConnectableObservable<T>
replay()
Returns aConnectableObservable
that shares a single subscription to the currentObservable
that will replay all of its items and notifications to any futureObserver
.@NonNull ConnectableObservable<T>
replay(int bufferSize)
Returns aConnectableObservable
that shares a single subscription to the currentObservable
that replays at mostbufferSize
items emitted by the currentObservable
.@NonNull ConnectableObservable<T>
replay(int bufferSize, boolean eagerTruncate)
Returns aConnectableObservable
that shares a single subscription to the currentObservable
that replays at mostbufferSize
items emitted by the currentObservable
.@NonNull ConnectableObservable<T>
replay(int bufferSize, long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns aConnectableObservable
that shares a single subscription to the currentObservable
and replays at mostbufferSize
items that were emitted during a specified time window.@NonNull ConnectableObservable<T>
replay(int bufferSize, long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aConnectableObservable
that shares a single subscription to the currentObservable
and that replays a maximum ofbufferSize
items that are emitted within a specified time window.@NonNull ConnectableObservable<T>
replay(int bufferSize, long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean eagerTruncate)
Returns aConnectableObservable
that shares a single subscription to the currentObservable
and that replays a maximum ofbufferSize
items that are emitted within a specified time window.@NonNull ConnectableObservable<T>
replay(long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns aConnectableObservable
that shares a single subscription to the currentObservable
and replays all items emitted by the currentObservable
within a specified time window.@NonNull ConnectableObservable<T>
replay(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aConnectableObservable
that shares a single subscription to the currentObservable
and replays all items emitted by the currentObservable
within a specified time window.@NonNull ConnectableObservable<T>
replay(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean eagerTruncate)
Returns aConnectableObservable
that shares a single subscription to the currentObservable
and replays all items emitted by the currentObservable
within a specified time window.<@NonNull R>
@NonNull Observable<R>replay(@NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector)
Returns anObservable
that emits items that are the results of invoking a specified selector on the items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
.<@NonNull R>
@NonNull Observable<R>replay(@NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector, int bufferSize)
Returns anObservable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
, replayingbufferSize
notifications.<@NonNull R>
@NonNull Observable<R>replay(@NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector, int bufferSize, boolean eagerTruncate)
Returns anObservable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
, replayingbufferSize
notifications.<@NonNull R>
@NonNull Observable<R>replay(@NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector, int bufferSize, long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
, replaying no more thanbufferSize
items that were emitted within a specified time window.<@NonNull R>
@NonNull Observable<R>replay(@NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector, int bufferSize, long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
, replaying no more thanbufferSize
items that were emitted within a specified time window.<@NonNull R>
@NonNull Observable<R>replay(@NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector, int bufferSize, long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean eagerTruncate)
Returns anObservable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
, replaying no more thanbufferSize
items that were emitted within a specified time window.<@NonNull R>
@NonNull Observable<R>replay(@NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector, long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
, replaying all items that were emitted within a specified time window.<@NonNull R>
@NonNull Observable<R>replay(@NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector, long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
, replaying all items that were emitted within a specified time window.<@NonNull R>
@NonNull Observable<R>replay(@NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector, long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean eagerTruncate)
Returns anObservable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
, replaying all items that were emitted within a specified time window.@NonNull Observable<T>
retry()
Returns anObservable
that mirrors the currentObservable
, resubscribing to it if it callsonError
(infinite retry count).@NonNull Observable<T>
retry(long times)
Returns anObservable
that mirrors the currentObservable
, resubscribing to it if it callsonError
up to a specified number of retries.@NonNull Observable<T>
retry(long times, @NonNull Predicate<? super java.lang.Throwable> predicate)
Retries at most times or until the predicate returnsfalse
, whichever happens first.@NonNull Observable<T>
retry(@NonNull BiPredicate<? super java.lang.Integer,? super java.lang.Throwable> predicate)
Returns anObservable
that mirrors the currentObservable
, resubscribing to it if it callsonError
and the predicate returnstrue
for that specific exception and retry count.@NonNull Observable<T>
retry(@NonNull Predicate<? super java.lang.Throwable> predicate)
Retries the currentObservable
if the predicate returnstrue
.@NonNull Observable<T>
retryUntil(@NonNull BooleanSupplier stop)
Retries until the given stop function returnstrue
.@NonNull Observable<T>
retryWhen(@NonNull Function<? super Observable<java.lang.Throwable>,? extends ObservableSource<?>> handler)
Returns anObservable
that emits the same values as the currentObservable
with the exception of anonError
.void
safeSubscribe(@NonNull Observer<? super @NonNull T> observer)
Subscribes to the currentObservable
and wraps the givenObserver
into aSafeObserver
(if not already aSafeObserver
) that deals with exceptions thrown by a misbehavingObserver
(that doesn't follow the Reactive Streams specification).@NonNull Observable<T>
sample(long period, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits the most recently emitted item (if any) emitted by the currentObservable
within periodic time intervals.@NonNull Observable<T>
sample(long period, @NonNull java.util.concurrent.TimeUnit unit, boolean emitLast)
Returns anObservable
that emits the most recently emitted item (if any) emitted by the currentObservable
within periodic time intervals and optionally emit the very last upstream item when the upstream completes.@NonNull Observable<T>
sample(long period, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that emits the most recently emitted item (if any) emitted by the currentObservable
within periodic time intervals, where the intervals are defined on a particularScheduler
.@NonNull Observable<T>
sample(long period, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean emitLast)
Returns anObservable
that emits the most recently emitted item (if any) emitted by the currentObservable
within periodic time intervals, where the intervals are defined on a particularScheduler
and optionally emit the very last upstream item when the upstream completes.@NonNull Observable<T>
sample(long period, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean emitLast, @NonNull Consumer<? super @NonNull T> onDropped)
Returns anObservable
that emits the most recently emitted item (if any) emitted by the currentObservable
within periodic time intervals, where the intervals are defined on a particularScheduler
.<@NonNull U>
@NonNull Observable<T>sample(@NonNull ObservableSource<@NonNull U> sampler)
Returns anObservable
that, when the specifiedsampler
ObservableSource
emits an item or completes, emits the most recently emitted item (if any) emitted by the currentObservable
since the previous emission from thesampler
ObservableSource
.<@NonNull U>
@NonNull Observable<T>sample(@NonNull ObservableSource<@NonNull U> sampler, boolean emitLast)
Returns anObservable
that, when the specifiedsampler
ObservableSource
emits an item or completes, emits the most recently emitted item (if any) emitted by the currentObservable
since the previous emission from thesampler
ObservableSource
and optionally emit the very last upstream item when the upstream or otherObservableSource
complete.@NonNull Observable<T>
scan(@NonNull BiFunction<@NonNull T,@NonNull T,@NonNull T> accumulator)
Returns anObservable
that emits the first value emitted by the currentObservable
, then emits one value for each subsequent value emitted by the currentObservable
.<@NonNull R>
@NonNull Observable<R>scan(@NonNull R initialValue, @NonNull BiFunction<@NonNull R,? super @NonNull T,@NonNull R> accumulator)
Returns anObservable
that emits the provided initial (seed) value, then emits one value for each value emitted by the currentObservable
.<@NonNull R>
@NonNull Observable<R>scanWith(@NonNull Supplier<@NonNull R> seedSupplier, @NonNull BiFunction<@NonNull R,? super @NonNull T,@NonNull R> accumulator)
Returns anObservable
that emits the provided initial (seed) value, then emits one value for each value emitted by the currentObservable
.static <@NonNull T>
@NonNull Single<java.lang.Boolean>sequenceEqual(@NonNull ObservableSource<? extends @NonNull T> source1, @NonNull ObservableSource<? extends @NonNull T> source2)
Returns aSingle
that emits aBoolean
value that indicates whether twoObservableSource
sequences are the same by comparing the items emitted by eachObservableSource
pairwise.static <@NonNull T>
@NonNull Single<java.lang.Boolean>sequenceEqual(@NonNull ObservableSource<? extends @NonNull T> source1, @NonNull ObservableSource<? extends @NonNull T> source2, int bufferSize)
Returns aSingle
that emits aBoolean
value that indicates whether twoObservableSource
sequences are the same by comparing the items emitted by eachObservableSource
pairwise.static <@NonNull T>
@NonNull Single<java.lang.Boolean>sequenceEqual(@NonNull ObservableSource<? extends @NonNull T> source1, @NonNull ObservableSource<? extends @NonNull T> source2, @NonNull BiPredicate<? super @NonNull T,? super @NonNull T> isEqual)
Returns aSingle
that emits aBoolean
value that indicates whether twoObservableSource
sequences are the same by comparing the items emitted by eachObservableSource
pairwise based on the results of a specified equality function.static <@NonNull T>
@NonNull Single<java.lang.Boolean>sequenceEqual(@NonNull ObservableSource<? extends @NonNull T> source1, @NonNull ObservableSource<? extends @NonNull T> source2, @NonNull BiPredicate<? super @NonNull T,? super @NonNull T> isEqual, int bufferSize)
Returns aSingle
that emits aBoolean
value that indicates whether twoObservableSource
sequences are the same by comparing the items emitted by eachObservableSource
pairwise based on the results of a specified equality function.@NonNull Observable<T>
serialize()
Forces the currentObservable
's emissions and notifications to be serialized and for it to obey theObservableSource
contract in other ways.@NonNull Observable<T>
share()
Returns a newObservable
that multicasts (and shares a single subscription to) the currentObservable
.@NonNull Single<T>
single(@NonNull T defaultItem)
Returns aSingle
that emits the single item emitted by the currentObservable
, if the currentObservable
emits only a single item, or a default item if the currentObservable
emits no items.@NonNull Maybe<T>
singleElement()
Returns aMaybe
that completes if the currentObservable
is empty or emits the single item emitted by the currentObservable
, or signals anIllegalArgumentException
if the currentObservable
emits more than one item.@NonNull Single<T>
singleOrError()
Returns aSingle
that emits the single item emitted by the currentObservable
if it emits only a single item, otherwise if the currentObservable
completes without emitting any items or emits more than one item aNoSuchElementException
orIllegalArgumentException
will be signaled respectively.@NonNull java.util.concurrent.CompletionStage<T>
singleOrErrorStage()
Signals the only expected upstream item, aNoSuchElementException
if the upstream is empty or signalsIllegalArgumentException
if the upstream has more than one item via aCompletionStage
.@NonNull java.util.concurrent.CompletionStage<T>
singleStage(@NonNull T defaultItem)
Signals the only expected upstream item (or the default item if the upstream is empty) or signalsIllegalArgumentException
if the upstream has more than one item via aCompletionStage
.@NonNull Observable<T>
skip(long count)
Returns anObservable
that skips the firstcount
items emitted by the currentObservable
and emits the remainder.@NonNull Observable<T>
skip(long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that skips values emitted by the currentObservable
before a specified time window elapses.@NonNull Observable<T>
skip(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that skips values emitted by the currentObservable
before a specified time window on a specifiedScheduler
elapses.@NonNull Observable<T>
skipLast(int count)
Returns anObservable
that drops a specified number of items from the end of the sequence emitted by the currentObservable
.@NonNull Observable<T>
skipLast(long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that drops items emitted by the currentObservable
during a specified time window before the source completes.@NonNull Observable<T>
skipLast(long time, @NonNull java.util.concurrent.TimeUnit unit, boolean delayError)
Returns anObservable
that drops items emitted by the currentObservable
during a specified time window before the source completes.@NonNull Observable<T>
skipLast(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that drops items emitted by the currentObservable
during a specified time window (defined on a specified scheduler) before the source completes.@NonNull Observable<T>
skipLast(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError)
Returns anObservable
that drops items emitted by the currentObservable
during a specified time window (defined on a specified scheduler) before the source completes.@NonNull Observable<T>
skipLast(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError, int bufferSize)
Returns anObservable
that drops items emitted by the currentObservable
during a specified time window (defined on a specified scheduler) before the source completes.<@NonNull U>
@NonNull Observable<T>skipUntil(@NonNull ObservableSource<@NonNull U> other)
Returns anObservable
that skips items emitted by the currentObservable
until a secondObservableSource
emits an item.@NonNull Observable<T>
skipWhile(@NonNull Predicate<? super @NonNull T> predicate)
Returns anObservable
that skips all items emitted by the currentObservable
as long as a specified condition holdstrue
, but emits all further source items as soon as the condition becomesfalse
.@NonNull Observable<T>
sorted()
Returns anObservable
that emits the events emitted by the currentObservable
, in a sorted order.@NonNull Observable<T>
sorted(@NonNull java.util.Comparator<? super @NonNull T> comparator)
Returns anObservable
that emits the events emitted by the currentObservable
, in a sorted order based on a specified comparison function.@NonNull Observable<T>
startWith(@NonNull CompletableSource other)
Returns anObservable
which first runs the otherCompletableSource
then the currentObservable
if the other completed normally.@NonNull Observable<T>
startWith(@NonNull MaybeSource<@NonNull T> other)
Returns anObservable
which first runs the otherMaybeSource
then the currentObservable
if the other succeeded or completed normally.@NonNull Observable<T>
startWith(@NonNull ObservableSource<? extends @NonNull T> other)
Returns anObservable
that emits the items in a specifiedObservableSource
before it begins to emit items emitted by the currentObservable
.@NonNull Observable<T>
startWith(@NonNull SingleSource<@NonNull T> other)
Returns anObservable
which first runs the otherSingleSource
then the currentObservable
if the other succeeded normally.@NonNull Observable<T>
startWithArray(@NonNull T... items)
Returns anObservable
that emits the specified items before it begins to emit items emitted by the currentObservable
.@NonNull Observable<T>
startWithItem(@NonNull T item)
Returns anObservable
that emits a specified item before it begins to emit items emitted by the currentObservable
.@NonNull Observable<T>
startWithIterable(@NonNull java.lang.Iterable<? extends @NonNull T> items)
Returns anObservable
that emits the items in a specifiedIterable
before it begins to emit items emitted by the currentObservable
.@NonNull Disposable
subscribe()
Subscribes to the currentObservable
and ignoresonNext
andonComplete
emissions.void
subscribe(@NonNull Observer<? super @NonNull T> observer)
Subscribes the givenObserver
to thisObservableSource
instance.@NonNull Disposable
subscribe(@NonNull Consumer<? super @NonNull T> onNext)
Subscribes to the currentObservable
and provides a callback to handle the items it emits.@NonNull Disposable
subscribe(@NonNull Consumer<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError)
Subscribes to the currentObservable
and provides callbacks to handle the items it emits and any error notification it signals.@NonNull Disposable
subscribe(@NonNull Consumer<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull Action onComplete)
Subscribes to the currentObservable
and provides callbacks to handle the items it emits and any error or completion notification it signals.@NonNull Disposable
subscribe(@NonNull Consumer<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull Action onComplete, @NonNull DisposableContainer container)
Wraps the given onXXX callbacks into aDisposable
Observer
, adds it to the givenDisposableContainer
and ensures, that if the upstream terminates or this particularDisposable
is disposed, theObserver
is removed from the given container.protected abstract void
subscribeActual(@NonNull Observer<? super @NonNull T> observer)
Operator implementations (both source and intermediate) should implement this method that performs the necessary business logic and handles the incomingObserver
s.@NonNull Observable<T>
subscribeOn(@NonNull Scheduler scheduler)
<@NonNull E extends Observer<? super @NonNull T>>
EsubscribeWith(@NonNull E observer)
Subscribes a givenObserver
(subclass) to the currentObservable
and returns the givenObserver
instance as is.@NonNull Observable<T>
switchIfEmpty(@NonNull ObservableSource<? extends @NonNull T> other)
Returns anObservable
that emits the items emitted by the currentObservable
or the items of an alternateObservableSource
if the currentObservable
is empty.<@NonNull R>
@NonNull Observable<R>switchMap(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper)
Returns a newObservable
by applying a function that you supply to each item emitted by the currentObservable
that returns anObservableSource
, and then emitting the items emitted by the most recently emitted of theseObservableSource
s.<@NonNull R>
@NonNull Observable<R>switchMap(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, int bufferSize)
Returns a newObservable
by applying a function that you supply to each item emitted by the currentObservable
that returns anObservableSource
, and then emitting the items emitted by the most recently emitted of theseObservableSource
s.@NonNull Completable
switchMapCompletable(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps the items of the currentObservable
intoCompletableSource
s, subscribes to the newer one while disposing the subscription to the previousCompletableSource
, thus keeping at most one activeCompletableSource
running.@NonNull Completable
switchMapCompletableDelayError(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps the upstream values intoCompletableSource
s, subscribes to the newer one while disposing the subscription to the previousCompletableSource
, thus keeping at most one activeCompletableSource
running and delaying any main or inner errors until all of them terminate.<@NonNull R>
@NonNull Observable<R>switchMapDelayError(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper)
Returns a newObservable
by applying a function that you supply to each item emitted by the currentObservable
that returns anObservableSource
, and then emitting the items emitted by the most recently emitted of theseObservableSource
s and delays any error until allObservableSource
s terminate.<@NonNull R>
@NonNull Observable<R>switchMapDelayError(@NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, int bufferSize)
Returns a newObservable
by applying a function that you supply to each item emitted by the currentObservable
that returns anObservableSource
, and then emitting the items emitted by the most recently emitted of theseObservableSource
s and delays any error until allObservableSource
s terminate.<@NonNull R>
@NonNull Observable<R>switchMapMaybe(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps the items of the currentObservable
intoMaybeSource
s and switches (subscribes) to the newer ones while disposing the older ones (and ignoring their signals) and emits the latest success value of the current one if available while failing immediately if the currentObservable
or any of the active innerMaybeSource
s fail.<@NonNull R>
@NonNull Observable<R>switchMapMaybeDelayError(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps the upstream items intoMaybeSource
s and switches (subscribes) to the newer ones while disposing the older ones (and ignoring their signals) and emits the latest success value of the current one if available, delaying errors from the currentObservable
or the innerMaybeSource
s until all terminate.<@NonNull R>
@NonNull Observable<R>switchMapSingle(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Returns a newObservable
by applying a function that you supply to each item emitted by the currentObservable
that returns aSingleSource
, and then emitting the item emitted by the most recently emitted of theseSingleSource
s.<@NonNull R>
@NonNull Observable<R>switchMapSingleDelayError(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Returns a newObservable
by applying a function that you supply to each item emitted by the currentObservable
that returns aSingleSource
, and then emitting the item emitted by the most recently emitted of theseSingleSource
s and delays any error until allSingleSource
s terminate.static <@NonNull T>
@NonNull Observable<T>switchOnNext(@NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
Converts anObservableSource
that emitsObservableSource
s into anObservable
that emits the items emitted by the most recently emitted of thoseObservableSource
s.static <@NonNull T>
@NonNull Observable<T>switchOnNext(@NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources, int bufferSize)
Converts anObservableSource
that emitsObservableSource
s into anObservable
that emits the items emitted by the most recently emitted of thoseObservableSource
s.static <@NonNull T>
@NonNull Observable<T>switchOnNextDelayError(@NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
Converts anObservableSource
that emitsObservableSource
s into anObservable
that emits the items emitted by the most recently emitted of thoseObservableSource
s and delays any exception until allObservableSource
s terminate.static <@NonNull T>
@NonNull Observable<T>switchOnNextDelayError(@NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources, int bufferSize)
Converts anObservableSource
that emitsObservableSource
s into anObservable
that emits the items emitted by the most recently emitted of thoseObservableSource
s and delays any exception until allObservableSource
s terminate.@NonNull Observable<T>
take(long count)
Returns anObservable
that emits only the firstcount
items emitted by the currentObservable
.@NonNull Observable<T>
take(long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits those items emitted by the currentObservable
before a specified time runs out.@NonNull Observable<T>
take(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that emits those items emitted by the currentObservable
before a specified time (on a specifiedScheduler
) runs out.@NonNull Observable<T>
takeLast(int count)
Returns anObservable
that emits at most the lastcount
items emitted by the currentObservable
.@NonNull Observable<T>
takeLast(long count, long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits at most a specified number of items from the currentObservable
that were emitted in a specified window of time before the currentObservable
completed.@NonNull Observable<T>
takeLast(long count, long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that emits at most a specified number of items from the currentObservable
that were emitted in a specified window of time before the currentObservable
completed, where the timing information is provided by a givenScheduler
.@NonNull Observable<T>
takeLast(long count, long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError, int bufferSize)
Returns anObservable
that emits at most a specified number of items from the currentObservable
that were emitted in a specified window of time before the currentObservable
completed, where the timing information is provided by a givenScheduler
.@NonNull Observable<T>
takeLast(long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits the items from the currentObservable
that were emitted in a specified window of time before the currentObservable
completed.@NonNull Observable<T>
takeLast(long time, @NonNull java.util.concurrent.TimeUnit unit, boolean delayError)
Returns anObservable
that emits the items from the currentObservable
that were emitted in a specified window of time before the currentObservable
completed.@NonNull Observable<T>
takeLast(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that emits the items from the currentObservable
that were emitted in a specified window of time before the currentObservable
completed, where the timing information is provided by a specifiedScheduler
.@NonNull Observable<T>
takeLast(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError)
Returns anObservable
that emits the items from the currentObservable
that were emitted in a specified window of time before the currentObservable
completed, where the timing information is provided by a specifiedScheduler
.@NonNull Observable<T>
takeLast(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError, int bufferSize)
Returns anObservable
that emits the items from the currentObservable
that were emitted in a specified window of time before the currentObservable
completed, where the timing information is provided by a specifiedScheduler
.<@NonNull U>
@NonNull Observable<T>takeUntil(@NonNull ObservableSource<@NonNull U> other)
Returns anObservable
that emits the items emitted by the currentObservable
until a secondObservableSource
emits an item or completes.@NonNull Observable<T>
takeUntil(@NonNull Predicate<? super @NonNull T> stopPredicate)
Returns anObservable
that emits items emitted by the currentObservable
, checks the specified predicate for each item, and then completes when the condition is satisfied.@NonNull Observable<T>
takeWhile(@NonNull Predicate<? super @NonNull T> predicate)
Returns anObservable
that emits items emitted by the currentObservable
so long as each item satisfied a specified condition, and then completes as soon as this condition is not satisfied.@NonNull TestObserver<T>
test()
Creates aTestObserver
and subscribes it to the currentObservable
.@NonNull TestObserver<T>
test(boolean dispose)
Creates aTestObserver
, optionally disposes it and then subscribes it to the currentObservable
.@NonNull Observable<T>
throttleFirst(long windowDuration, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits only the first item emitted by the currentObservable
during sequential time windows of a specified duration.@NonNull Observable<T>
throttleFirst(long skipDuration, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that emits only the first item emitted by the currentObservable
during sequential time windows of a specified duration, where the windows are managed by a specifiedScheduler
.@NonNull Observable<T>
throttleFirst(long skipDuration, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, @NonNull Consumer<? super @NonNull T> onDropped)
Returns anObservable
that emits only the first item emitted by the currentObservable
during sequential time windows of a specified duration, where the windows are managed by a specifiedScheduler
.@NonNull Observable<T>
throttleLast(long intervalDuration, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits only the last item emitted by the currentObservable
during sequential time windows of a specified duration.@NonNull Observable<T>
throttleLast(long intervalDuration, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that emits only the last item emitted by the currentObservable
during sequential time windows of a specified duration, where the duration is governed by a specifiedScheduler
.@NonNull Observable<T>
throttleLast(long intervalDuration, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, @NonNull Consumer<? super @NonNull T> onDropped)
Returns anObservable
that emits only the last item emitted by the currentObservable
during sequential time windows of a specified duration, where the duration is governed by a specifiedScheduler
.@NonNull Observable<T>
throttleLatest(long timeout, @NonNull java.util.concurrent.TimeUnit unit)
Throttles items from the currentObservable
by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them.@NonNull Observable<T>
throttleLatest(long timeout, @NonNull java.util.concurrent.TimeUnit unit, boolean emitLast)
Throttles items from the currentObservable
by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them.@NonNull Observable<T>
throttleLatest(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Throttles items from the currentObservable
by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them.@NonNull Observable<T>
throttleLatest(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean emitLast)
Throttles items from the currentObservable
by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them.@NonNull Observable<T>
throttleLatest(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean emitLast, @NonNull Consumer<? super @NonNull T> onDropped)
Throttles items from the currentObservable
by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them, invoking the consumer for any dropped item.@NonNull Observable<T>
throttleWithTimeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that mirrors the currentObservable
, except that it drops items emitted by the currentObservable
that are followed by newer items before a timeout value expires.@NonNull Observable<T>
throttleWithTimeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that mirrors the currentObservable
, except that it drops items emitted by the currentObservable
that are followed by newer items before a timeout value expires on a specifiedScheduler
.@NonNull Observable<T>
throttleWithTimeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, @NonNull Consumer<? super @NonNull T> onDropped)
Returns anObservable
that mirrors the currentObservable
, except that it drops items emitted by the currentObservable
that are followed by newer items before a timeout value expires on a specifiedScheduler
.@NonNull Observable<Timed<T>>
timeInterval()
Returns anObservable
that emits records of the time interval between consecutive items emitted by the currentObservable
.@NonNull Observable<Timed<T>>
timeInterval(@NonNull Scheduler scheduler)
Returns anObservable
that emits records of the time interval between consecutive items emitted by the currentObservable
, where this interval is computed on a specifiedScheduler
.@NonNull Observable<Timed<T>>
timeInterval(@NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits records of the time interval between consecutive items emitted by the currentObservable
.@NonNull Observable<Timed<T>>
timeInterval(@NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that emits records of the time interval between consecutive items emitted by the currentObservable
, where this interval is computed on a specifiedScheduler
.@NonNull Observable<T>
timeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that mirrors the currentObservable
but applies a timeout policy for each emitted item.@NonNull Observable<T>
timeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull ObservableSource<? extends @NonNull T> fallback)
Returns anObservable
that mirrors the currentObservable
but applies a timeout policy for each emitted item.@NonNull Observable<T>
timeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that mirrors the currentObservable
but applies a timeout policy for each emitted item, where this policy is governed on a specifiedScheduler
.@NonNull Observable<T>
timeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, @NonNull ObservableSource<? extends @NonNull T> fallback)
Returns anObservable
that mirrors the currentObservable
but applies a timeout policy for each emitted item using a specifiedScheduler
.<@NonNull U,@NonNull V>
@NonNull Observable<T>timeout(@NonNull ObservableSource<@NonNull U> firstTimeoutIndicator, @NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull V>> itemTimeoutIndicator)
Returns anObservable
that mirrors the currentObservable
, but notifies observers of aTimeoutException
if either the first item emitted by the currentObservable
or any subsequent item doesn't arrive within time windows defined by indicatorObservableSource
s.<@NonNull U,@NonNull V>
@NonNull Observable<T>timeout(@NonNull ObservableSource<@NonNull U> firstTimeoutIndicator, @NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull V>> itemTimeoutIndicator, @NonNull ObservableSource<? extends @NonNull T> fallback)
Returns anObservable
that mirrors the currentObservable
, but switches to a fallbackObservableSource
if either the first item emitted by the currentObservable
or any subsequent item doesn't arrive within time windows defined by indicatorObservableSource
s.<@NonNull V>
@NonNull Observable<T>timeout(@NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull V>> itemTimeoutIndicator)
Returns anObservable
that mirrors the currentObservable
, but notifies observers of aTimeoutException
if an item emitted by the currentObservable
doesn't arrive within a window of time after the emission of the previous item, where that period of time is measured by anObservableSource
that is a function of the previous item.<@NonNull V>
@NonNull Observable<T>timeout(@NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull V>> itemTimeoutIndicator, @NonNull ObservableSource<? extends @NonNull T> fallback)
Returns anObservable
that mirrors the currentObservable
, but that switches to a fallbackObservableSource
if an item emitted by the currentObservable
doesn't arrive within a window of time after the emission of the previous item, where that period of time is measured by anObservableSource
that is a function of the previous item.private @NonNull Observable<T>
timeout0(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @Nullable ObservableSource<? extends @NonNull T> fallback, @NonNull Scheduler scheduler)
private <U,V>
@NonNull Observable<T>timeout0(@NonNull ObservableSource<U> firstTimeoutIndicator, @NonNull Function<? super @NonNull T,? extends ObservableSource<V>> itemTimeoutIndicator, @Nullable ObservableSource<? extends @NonNull T> fallback)
static @NonNull Observable<java.lang.Long>
timer(long delay, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits0L
after a specified delay, and then completes.static @NonNull Observable<java.lang.Long>
timer(long delay, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that emits0L
after a specified delay, on a specifiedScheduler
, and then completes.@NonNull Observable<Timed<T>>
timestamp()
Returns anObservable
that emits each item emitted by the currentObservable
, wrapped in aTimed
object.@NonNull Observable<Timed<T>>
timestamp(@NonNull Scheduler scheduler)
@NonNull Observable<Timed<T>>
timestamp(@NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits each item emitted by the currentObservable
, wrapped in aTimed
object.@NonNull Observable<Timed<T>>
timestamp(@NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
<@NonNull R>
Rto(@NonNull ObservableConverter<@NonNull T,? extends @NonNull R> converter)
Calls the specified converter function during assembly time and returns its resulting value.@NonNull Flowable<T>
toFlowable(@NonNull BackpressureStrategy strategy)
Converts the currentObservable
into aFlowable
by applying the specified backpressure strategy.@NonNull java.util.concurrent.Future<T>
toFuture()
Returns aFuture
representing the only value emitted by the currentObservable
.@NonNull Single<@NonNull java.util.List<T>>
toList()
Returns aSingle
that emits a single item, aList
composed of all the items emitted by the current and finiteObservable
.@NonNull Single<@NonNull java.util.List<T>>
toList(int capacityHint)
Returns aSingle
that emits a single item, aList
composed of all the items emitted by the current and finiteObservable
.<@NonNull U extends java.util.Collection<? super @NonNull T>>
@NonNull Single<U>toList(@NonNull Supplier<@NonNull U> collectionSupplier)
Returns aSingle
that emits a single item, aCollection
(subclass) composed of all the items emitted by the finite upstreamObservable
.<@NonNull K>
@NonNull Single<@NonNull java.util.Map<K,T>>toMap(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector)
Returns aSingle
that emits a singleHashMap
containing all items emitted by the current and finiteObservable
, mapped by the keys returned by a specifiedkeySelector
function.<@NonNull K,@NonNull V>
@NonNull Single<java.util.Map<K,V>>toMap(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector)
Returns aSingle
that emits a singleHashMap
containing values corresponding to items emitted by the current and finiteObservable
, mapped by the keys and values returned by the given selector functions.<@NonNull K,@NonNull V>
@NonNull Single<java.util.Map<K,V>>toMap(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector, @NonNull Supplier<? extends java.util.Map<@NonNull K,@NonNull V>> mapSupplier)
Returns aSingle
that emits a singleMap
(subclass), returned by a specifiedmapFactory
function, that contains keys and values extracted from the items, via selector functions, emitted by the current and finiteObservable
.<@NonNull K>
@NonNull Single<@NonNull java.util.Map<K,java.util.Collection<T>>>toMultimap(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector)
Returns aSingle
that emits a singleHashMap
that contains anArrayList
of items emitted by the current and finiteObservable
keyed by a specifiedkeySelector
function.<@NonNull K,@NonNull V>
@NonNull Single<@NonNull java.util.Map<K,java.util.Collection<V>>>toMultimap(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector, @NonNull Supplier<? extends java.util.Map<@NonNull K,java.util.Collection<@NonNull V>>> mapSupplier, @NonNull Function<? super @NonNull K,? extends java.util.Collection<? super @NonNull V>> collectionFactory)
Returns aSingle
that emits a singleMap
(subclass), returned by a specifiedmapFactory
function, that contains a customCollection
of values, extracted by a specifiedvalueSelector
function from items emitted by the current and finiteObservable
, and keyed by thekeySelector
function.<@NonNull K,@NonNull V>
@NonNull Single<@NonNull java.util.Map<K,java.util.Collection<V>>>toMultimap(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector, @NonNull Supplier<java.util.Map<@NonNull K,java.util.Collection<@NonNull V>>> mapSupplier)
Returns aSingle
that emits a singleMap
(subclass), returned by a specifiedmapFactory
function, that contains anArrayList
of values, extracted by a specifiedvalueSelector
function from items emitted by the current and finiteObservable
and keyed by thekeySelector
function.<@NonNull K,@NonNull V>
@NonNull Single<@NonNull java.util.Map<K,java.util.Collection<V>>>toMultimap(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, Function<? super @NonNull T,? extends @NonNull V> valueSelector)
Returns aSingle
that emits a singleHashMap
that contains anArrayList
of values extracted by a specifiedvalueSelector
function from items emitted by the current and finiteObservable
, keyed by a specifiedkeySelector
function.@NonNull Single<@NonNull java.util.List<T>>
toSortedList()
Returns aSingle
that emits aList
that contains the items emitted by the current and finiteObservable
, in a sorted order.@NonNull Single<@NonNull java.util.List<T>>
toSortedList(int capacityHint)
Returns aSingle
that emits aList
that contains the items emitted by the current and finiteObservable
, in a sorted order.@NonNull Single<@NonNull java.util.List<T>>
toSortedList(@NonNull java.util.Comparator<? super @NonNull T> comparator)
Returns aSingle
that emits aList
that contains the items emitted by the current and finiteObservable
, in a sorted order based on a specified comparison function.@NonNull Single<@NonNull java.util.List<T>>
toSortedList(@NonNull java.util.Comparator<? super @NonNull T> comparator, int capacityHint)
Returns aSingle
that emits aList
that contains the items emitted by the current and finiteObservable
, in a sorted order based on a specified comparison function.static <@NonNull T>
@NonNull Observable<T>unsafeCreate(@NonNull ObservableSource<@NonNull T> onSubscribe)
Create anObservable
by wrapping anObservableSource
which has to be implemented according to theObservable
specification derived from the Reactive Streams specification by handling disposal correctly; no safeguards are provided by theObservable
itself.@NonNull Observable<T>
unsubscribeOn(@NonNull Scheduler scheduler)
static <@NonNull T,@NonNull D>
@NonNull Observable<T>using(@NonNull Supplier<? extends @NonNull D> resourceSupplier, @NonNull Function<? super @NonNull D,? extends ObservableSource<? extends @NonNull T>> sourceSupplier, @NonNull Consumer<? super @NonNull D> resourceCleanup)
Constructs anObservable
that creates a dependent resource object, anObservableSource
with that resource and calls the providedresourceDisposer
function if this inner source terminates or the downstream disposes the flow.static <@NonNull T,@NonNull D>
@NonNull Observable<T>using(@NonNull Supplier<? extends @NonNull D> resourceSupplier, @NonNull Function<? super @NonNull D,? extends ObservableSource<? extends @NonNull T>> sourceSupplier, @NonNull Consumer<? super @NonNull D> resourceCleanup, boolean eager)
Constructs anObservable
that creates a dependent resource object, anObservableSource
with that resource and calls the provideddisposer
function if this inner source terminates or the downstream disposes the flow; doing it before these end-states have been reached ifeager == true
, after otherwise.@NonNull Observable<Observable<T>>
window(long count)
Returns anObservable
that emits windows of items it collects from the currentObservable
.@NonNull Observable<Observable<T>>
window(long count, long skip)
Returns anObservable
that emits windows of items it collects from the currentObservable
.@NonNull Observable<Observable<T>>
window(long count, long skip, int bufferSize)
Returns anObservable
that emits windows of items it collects from the currentObservable
.@NonNull Observable<Observable<T>>
window(long timespan, long timeskip, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits windows of items it collects from the currentObservable
.@NonNull Observable<Observable<T>>
window(long timespan, long timeskip, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that emits windows of items it collects from the currentObservable
.@NonNull Observable<Observable<T>>
window(long timespan, long timeskip, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, int bufferSize)
Returns anObservable
that emits windows of items it collects from the currentObservable
.@NonNull Observable<Observable<T>>
window(long timespan, @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits windows of items it collects from the currentObservable
.@NonNull Observable<Observable<T>>
window(long timespan, @NonNull java.util.concurrent.TimeUnit unit, long count)
Returns anObservable
that emits windows of items it collects from the currentObservable
.@NonNull Observable<Observable<T>>
window(long timespan, @NonNull java.util.concurrent.TimeUnit unit, long count, boolean restart)
Returns anObservable
that emits windows of items it collects from the currentObservable
.@NonNull Observable<Observable<T>>
window(long timespan, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns anObservable
that emits windows of items it collects from the currentObservable
.@NonNull Observable<Observable<T>>
window(long timespan, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, long count)
Returns anObservable
that emits windows of items it collects from the currentObservable
.@NonNull Observable<Observable<T>>
window(long timespan, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, long count, boolean restart)
Returns anObservable
that emits windows of items it collects from the currentObservable
.@NonNull Observable<Observable<T>>
window(long timespan, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, long count, boolean restart, int bufferSize)
Returns anObservable
that emits windows of items it collects from the currentObservable
.<@NonNull B>
@NonNull Observable<Observable<T>>window(@NonNull ObservableSource<@NonNull B> boundaryIndicator)
Returns anObservable
that emits non-overlapping windows of items it collects from the currentObservable
where the boundary of each window is determined by the items emitted from a specified boundary-governingObservableSource
.<@NonNull B>
@NonNull Observable<Observable<T>>window(@NonNull ObservableSource<@NonNull B> boundaryIndicator, int bufferSize)
Returns anObservable
that emits non-overlapping windows of items it collects from the currentObservable
where the boundary of each window is determined by the items emitted from a specified boundary-governingObservableSource
.<@NonNull U,@NonNull V>
@NonNull Observable<Observable<T>>window(@NonNull ObservableSource<@NonNull U> openingIndicator, @NonNull Function<? super @NonNull U,? extends ObservableSource<@NonNull V>> closingIndicator)
Returns anObservable
that emits windows of items it collects from the currentObservable
.<@NonNull U,@NonNull V>
@NonNull Observable<Observable<T>>window(@NonNull ObservableSource<@NonNull U> openingIndicator, @NonNull Function<? super @NonNull U,? extends ObservableSource<@NonNull V>> closingIndicator, int bufferSize)
Returns anObservable
that emits windows of items it collects from the currentObservable
.<@NonNull R>
@NonNull Observable<R>withLatestFrom(@NonNull ObservableSource<?>[] others, @NonNull Function<? super java.lang.Object[],@NonNull R> combiner)
Combines the value emission from the currentObservable
with the latest emissions from the otherObservableSource
s via a function to produce the output item.<@NonNull U,@NonNull R>
@NonNull Observable<R>withLatestFrom(@NonNull ObservableSource<? extends @NonNull U> other, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner)
Merges the specifiedObservableSource
into the currentObservable
sequence by using theresultSelector
function only when the currentObservable
emits an item.<@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull R>
@NonNull Observable<R>withLatestFrom(@NonNull ObservableSource<@NonNull T1> source1, @NonNull ObservableSource<@NonNull T2> source2, @NonNull ObservableSource<@NonNull T3> source3, @NonNull ObservableSource<@NonNull T4> source4, @NonNull Function5<? super @NonNull T,? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,@NonNull R> combiner)
Combines the value emission from the currentObservable
with the latest emissions from the otherObservableSource
s via a function to produce the output item.<@NonNull T1,@NonNull T2,@NonNull T3,@NonNull R>
@NonNull Observable<R>withLatestFrom(@NonNull ObservableSource<@NonNull T1> source1, @NonNull ObservableSource<@NonNull T2> source2, @NonNull ObservableSource<@NonNull T3> source3, @NonNull Function4<? super @NonNull T,? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,@NonNull R> combiner)
Combines the value emission from the currentObservable
with the latest emissions from the otherObservableSource
s via a function to produce the output item.<@NonNull T1,@NonNull T2,@NonNull R>
@NonNull Observable<R>withLatestFrom(@NonNull ObservableSource<@NonNull T1> source1, @NonNull ObservableSource<@NonNull T2> source2, @NonNull Function3<? super @NonNull T,? super @NonNull T1,? super @NonNull T2,@NonNull R> combiner)
Combines the value emission from the currentObservable
with the latest emissions from the otherObservableSource
s via a function to produce the output item.<@NonNull R>
@NonNull Observable<R>withLatestFrom(@NonNull java.lang.Iterable<? extends ObservableSource<?>> others, @NonNull Function<? super java.lang.Object[],@NonNull R> combiner)
Combines the value emission from the currentObservable
with the latest emissions from the otherObservableSource
s via a function to produce the output item.static <@NonNull T>
@NonNull Observable<T>wrap(@NonNull ObservableSource<@NonNull T> source)
static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull T9,@NonNull R>
@NonNull Observable<R>zip(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull ObservableSource<? extends @NonNull T6> source6, @NonNull ObservableSource<? extends @NonNull T7> source7, @NonNull ObservableSource<? extends @NonNull T8> source8, @NonNull ObservableSource<? extends @NonNull T9> source9, @NonNull Function9<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? super @NonNull T8,? super @NonNull T9,? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of nine items emitted, in sequence, by nine otherObservableSource
s.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull R>
@NonNull Observable<R>zip(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull ObservableSource<? extends @NonNull T6> source6, @NonNull ObservableSource<? extends @NonNull T7> source7, @NonNull ObservableSource<? extends @NonNull T8> source8, @NonNull Function8<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? super @NonNull T8,? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of eight items emitted, in sequence, by eight otherObservableSource
s.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull R>
@NonNull Observable<R>zip(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull ObservableSource<? extends @NonNull T6> source6, @NonNull ObservableSource<? extends @NonNull T7> source7, @NonNull Function7<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of seven items emitted, in sequence, by seven otherObservableSource
s.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull R>
@NonNull Observable<R>zip(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull ObservableSource<? extends @NonNull T6> source6, @NonNull Function6<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of six items emitted, in sequence, by six otherObservableSource
s.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull R>
@NonNull Observable<R>zip(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull Function5<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of five items emitted, in sequence, by five otherObservableSource
s.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull R>
@NonNull Observable<R>zip(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull Function4<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of four items emitted, in sequence, by four otherObservableSource
s.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull R>
@NonNull Observable<R>zip(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull Function3<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of three items emitted, in sequence, by three otherObservableSource
s.static <@NonNull T1,@NonNull T2,@NonNull R>
@NonNull Observable<R>zip(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two otherObservableSource
s.static <@NonNull T1,@NonNull T2,@NonNull R>
@NonNull Observable<R>zip(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> zipper, boolean delayError)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two otherObservableSource
s.static <@NonNull T1,@NonNull T2,@NonNull R>
@NonNull Observable<R>zip(@NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> zipper, boolean delayError, int bufferSize)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two otherObservableSource
s.static <@NonNull T,@NonNull R>
@NonNull Observable<R>zip(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by anIterable
of otherObservableSource
s.static <@NonNull T,@NonNull R>
@NonNull Observable<R>zip(@NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> zipper, boolean delayError, int bufferSize)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by anIterable
of otherObservableSource
s.static <@NonNull T,@NonNull R>
@NonNull Observable<R>zipArray(@NonNull Function<? super java.lang.Object[],? extends @NonNull R> zipper, boolean delayError, int bufferSize, @NonNull ObservableSource<? extends @NonNull T>... sources)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by an array of otherObservableSource
s.<@NonNull U,@NonNull R>
@NonNull Observable<R>zipWith(@NonNull ObservableSource<? extends @NonNull U> other, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper)
Returns anObservable
that emits items that are the result of applying a specified function to pairs of values, one each from the currentObservable
and another specifiedObservableSource
.<@NonNull U,@NonNull R>
@NonNull Observable<R>zipWith(@NonNull ObservableSource<? extends @NonNull U> other, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper, boolean delayError)
Returns anObservable
that emits items that are the result of applying a specified function to pairs of values, one each from the currentObservable
and another specifiedObservableSource
.<@NonNull U,@NonNull R>
@NonNull Observable<R>zipWith(@NonNull ObservableSource<? extends @NonNull U> other, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper, boolean delayError, int bufferSize)
Returns anObservable
that emits items that are the result of applying a specified function to pairs of values, one each from the currentObservable
and another specifiedObservableSource
.<@NonNull U,@NonNull R>
@NonNull Observable<R>zipWith(@NonNull java.lang.Iterable<@NonNull U> other, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper)
Returns anObservable
that emits items that are the result of applying a specified function to pairs of values, one each from the currentObservable
and a specifiedIterable
sequence.
-
-
-
Method Detail
-
amb
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> amb(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
Mirrors the oneObservableSource
in anIterable
of severalObservableSource
s that first either emits an item or sends a termination notification.When one of the
ObservableSource
s signal an item or terminates first, all subscriptions to the otherObservableSource
s are disposed.- Scheduler:
amb
does not operate by default on a particularScheduler
.- Error handling:
-
If any of the losing
ObservableSource
s signals an error, the error is routed to the global error handler viaRxJavaPlugins.onError(Throwable)
.
- Type Parameters:
T
- the common element type- Parameters:
sources
- anIterable
ofObservableSource
sources competing to react first. A subscription to each source will occur in the same order as in theIterable
.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Amb
-
ambArray
@CheckReturnValue @NonNull @SchedulerSupport("none") @SafeVarargs public static <@NonNull T> @NonNull Observable<T> ambArray(@NonNull @NonNull ObservableSource<? extends @NonNull T>... sources)
Mirrors the oneObservableSource
in an array of severalObservableSource
s that first either emits an item or sends a termination notification.When one of the
ObservableSource
s signal an item or terminates first, all subscriptions to the otherObservableSource
s are disposed.- Scheduler:
ambArray
does not operate by default on a particularScheduler
.- Error handling:
-
If any of the losing
ObservableSource
s signals an error, the error is routed to the global error handler viaRxJavaPlugins.onError(Throwable)
.
- Type Parameters:
T
- the common element type- Parameters:
sources
- an array ofObservableSource
sources competing to react first. A subscription to each source will occur in the same order as in the array.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Amb
-
bufferSize
@CheckReturnValue public static int bufferSize()
Returns the default 'island' size or capacity-increment hint for unbounded buffers.Delegates to
Flowable.bufferSize()
but is public for convenience.The value can be overridden via system parameter
rx3.buffer-size
before theFlowable
class is loaded.- Returns:
- the default 'island' size or capacity-increment hint
-
combineLatest
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T,@NonNull R> @NonNull Observable<R> combineLatest(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner)
Combines a collection of sourceObservableSource
s by emitting an item that aggregates the latest values of each of the returnedObservableSource
s each time an item is received from any of the returnedObservableSource
s, where this aggregation is defined by a specified function.Note on method signature: since Java doesn't allow creating a generic array with
new T[]
, the implementation of this operator has to create anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.
If the provided iterable of
ObservableSource
s is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.- Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base type of source valuesR
- the result type- Parameters:
sources
- the collection of sourceObservableSource
scombiner
- the aggregation function used to combine the items emitted by the returnedObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T,@NonNull R> @NonNull Observable<R> combineLatest(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner, int bufferSize)
Combines anIterable
of sourceObservableSource
s by emitting an item that aggregates the latest values of each of the returnedObservableSource
s each time an item is received from any of the returnedObservableSource
s, where this aggregation is defined by a specified function.Note on method signature: since Java doesn't allow creating a generic array with
new T[]
, the implementation of this operator has to create anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.
If the provided
Iterable
ofObservableSource
s is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.- Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base type of source valuesR
- the result type- Parameters:
sources
- the collection of sourceObservableSource
scombiner
- the aggregation function used to combine the items emitted by the returnedObservableSource
sbufferSize
- the expected number of row combination items to be buffered internally- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
orcombiner
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatestArray
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T,@NonNull R> @NonNull Observable<R> combineLatestArray(@NonNull @NonNull ObservableSource<? extends @NonNull T>[] sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner)
Combines an array of sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of the returnedObservableSource
s, where this aggregation is defined by a specified function.Note on method signature: since Java doesn't allow creating a generic array with
new T[]
, the implementation of this operator has to create anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.
If the provided array of
ObservableSource
s is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.- Scheduler:
combineLatestArray
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base type of source valuesR
- the result type- Parameters:
sources
- the collection of sourceObservableSource
scombiner
- the aggregation function used to combine the items emitted by theObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatestArray
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T,@NonNull R> @NonNull Observable<R> combineLatestArray(@NonNull @NonNull ObservableSource<? extends @NonNull T>[] sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner, int bufferSize)
Combines an array of sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.Note on method signature: since Java doesn't allow creating a generic array with
new T[]
, the implementation of this operator has to create anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.
If the provided array of
ObservableSource
s is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.- Scheduler:
combineLatestArray
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base type of source valuesR
- the result type- Parameters:
sources
- the collection of sourceObservableSource
scombiner
- the aggregation function used to combine the items emitted by theObservableSource
sbufferSize
- the expected number of row combination items to be buffered internally- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
orcombiner
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull R> @NonNull Observable<R> combineLatest(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> combiner)
Combines two sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from either of theObservableSource
s, where this aggregation is defined by a specified function.If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.
- Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the element type of the first sourceT2
- the element type of the second sourceR
- the combined output type- Parameters:
source1
- the first sourceObservableSource
source2
- the second sourceObservableSource
combiner
- the aggregation function used to combine the items emitted by theObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull R> @NonNull Observable<R> combineLatest(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull @NonNull Function3<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? extends @NonNull R> combiner)
Combines three sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.
- Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the element type of the first sourceT2
- the element type of the second sourceT3
- the element type of the third sourceR
- the combined output type- Parameters:
source1
- the first sourceObservableSource
source2
- the second sourceObservableSource
source3
- the third sourceObservableSource
combiner
- the aggregation function used to combine the items emitted by theObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull R> @NonNull Observable<R> combineLatest(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull @NonNull Function4<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? extends @NonNull R> combiner)
Combines four sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.
- Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the element type of the first sourceT2
- the element type of the second sourceT3
- the element type of the third sourceT4
- the element type of the fourth sourceR
- the combined output type- Parameters:
source1
- the first sourceObservableSource
source2
- the second sourceObservableSource
source3
- the third sourceObservableSource
source4
- the fourth sourceObservableSource
combiner
- the aggregation function used to combine the items emitted by theObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull R> @NonNull Observable<R> combineLatest(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull @NonNull Function5<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? extends @NonNull R> combiner)
Combines five sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.
- Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the element type of the first sourceT2
- the element type of the second sourceT3
- the element type of the third sourceT4
- the element type of the fourth sourceT5
- the element type of the fifth sourceR
- the combined output type- Parameters:
source1
- the first sourceObservableSource
source2
- the second sourceObservableSource
source3
- the third sourceObservableSource
source4
- the fourth sourceObservableSource
source5
- the fifth sourceObservableSource
combiner
- the aggregation function used to combine the items emitted by theObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull R> @NonNull Observable<R> combineLatest(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull @NonNull ObservableSource<? extends @NonNull T6> source6, @NonNull @NonNull Function6<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? extends @NonNull R> combiner)
Combines six sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.
- Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the element type of the first sourceT2
- the element type of the second sourceT3
- the element type of the third sourceT4
- the element type of the fourth sourceT5
- the element type of the fifth sourceT6
- the element type of the sixth sourceR
- the combined output type- Parameters:
source1
- the first sourceObservableSource
source2
- the second sourceObservableSource
source3
- the third sourceObservableSource
source4
- the fourth sourceObservableSource
source5
- the fifth sourceObservableSource
source6
- the sixth sourceObservableSource
combiner
- the aggregation function used to combine the items emitted by theObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
,source6
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull R> @NonNull Observable<R> combineLatest(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull @NonNull ObservableSource<? extends @NonNull T6> source6, @NonNull @NonNull ObservableSource<? extends @NonNull T7> source7, @NonNull @NonNull Function7<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? extends @NonNull R> combiner)
Combines seven sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.
- Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the element type of the first sourceT2
- the element type of the second sourceT3
- the element type of the third sourceT4
- the element type of the fourth sourceT5
- the element type of the fifth sourceT6
- the element type of the sixth sourceT7
- the element type of the seventh sourceR
- the combined output type- Parameters:
source1
- the first sourceObservableSource
source2
- the second sourceObservableSource
source3
- the third sourceObservableSource
source4
- the fourth sourceObservableSource
source5
- the fifth sourceObservableSource
source6
- the sixth sourceObservableSource
source7
- the seventh sourceObservableSource
combiner
- the aggregation function used to combine the items emitted by theObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
,source6
,source7
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull R> @NonNull Observable<R> combineLatest(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull @NonNull ObservableSource<? extends @NonNull T6> source6, @NonNull @NonNull ObservableSource<? extends @NonNull T7> source7, @NonNull @NonNull ObservableSource<? extends @NonNull T8> source8, @NonNull @NonNull Function8<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? super @NonNull T8,? extends @NonNull R> combiner)
Combines eight sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.
- Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the element type of the first sourceT2
- the element type of the second sourceT3
- the element type of the third sourceT4
- the element type of the fourth sourceT5
- the element type of the fifth sourceT6
- the element type of the sixth sourceT7
- the element type of the seventh sourceT8
- the element type of the eighth sourceR
- the combined output type- Parameters:
source1
- the first sourceObservableSource
source2
- the second sourceObservableSource
source3
- the third sourceObservableSource
source4
- the fourth sourceObservableSource
source5
- the fifth sourceObservableSource
source6
- the sixth sourceObservableSource
source7
- the seventh sourceObservableSource
source8
- the eighth sourceObservableSource
combiner
- the aggregation function used to combine the items emitted by theObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
,source6
,source7
,source8
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull T9,@NonNull R> @NonNull Observable<R> combineLatest(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull @NonNull ObservableSource<? extends @NonNull T6> source6, @NonNull @NonNull ObservableSource<? extends @NonNull T7> source7, @NonNull @NonNull ObservableSource<? extends @NonNull T8> source8, @NonNull @NonNull ObservableSource<? extends @NonNull T9> source9, @NonNull @NonNull Function9<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? super @NonNull T8,? super @NonNull T9,? extends @NonNull R> combiner)
Combines nine sourceObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.
- Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the element type of the first sourceT2
- the element type of the second sourceT3
- the element type of the third sourceT4
- the element type of the fourth sourceT5
- the element type of the fifth sourceT6
- the element type of the sixth sourceT7
- the element type of the seventh sourceT8
- the element type of the eighth sourceT9
- the element type of the ninth sourceR
- the combined output type- Parameters:
source1
- the first sourceObservableSource
source2
- the second sourceObservableSource
source3
- the third sourceObservableSource
source4
- the fourth sourceObservableSource
source5
- the fifth sourceObservableSource
source6
- the sixth sourceObservableSource
source7
- the seventh sourceObservableSource
source8
- the eighth sourceObservableSource
source9
- the ninth sourceObservableSource
combiner
- the aggregation function used to combine the items emitted by theObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
,source6
,source7
,source8
,source9
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatestArrayDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T,@NonNull R> @NonNull Observable<R> combineLatestArrayDelayError(@NonNull @NonNull ObservableSource<? extends @NonNull T>[] sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner)
Combines an array ofObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function.Note on method signature: since Java doesn't allow creating a generic array with
new T[]
, the implementation of this operator has to create anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.
If the provided array of
ObservableSource
s is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.- Scheduler:
combineLatestArrayDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base type of source valuesR
- the result type- Parameters:
sources
- the collection of sourceObservableSource
scombiner
- the aggregation function used to combine the items emitted by theObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatestArrayDelayError
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T,@NonNull R> @NonNull Observable<R> combineLatestArrayDelayError(@NonNull @NonNull ObservableSource<? extends @NonNull T>[] sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner, int bufferSize)
Combines an array ofObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function and delays any error from the sources until all sourceObservableSource
s terminate.Note on method signature: since Java doesn't allow creating a generic array with
new T[]
, the implementation of this operator has to create anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.
If the provided array of
ObservableSource
s is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.- Scheduler:
combineLatestArrayDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base type of source valuesR
- the result type- Parameters:
sources
- the collection of sourceObservableSource
scombiner
- the aggregation function used to combine the items emitted by theObservableSource
sbufferSize
- the expected number of row combination items to be buffered internally- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
orcombiner
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatestDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T,@NonNull R> @NonNull Observable<R> combineLatestDelayError(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner)
Combines anIterable
ofObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function and delays any error from the sources until all sourceObservableSource
s terminate.Note on method signature: since Java doesn't allow creating a generic array with
new T[]
, the implementation of this operator has to create anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.
If the provided iterable of
ObservableSource
s is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.- Scheduler:
combineLatestDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base type of source valuesR
- the result type- Parameters:
sources
- theIterable
of sourceObservableSource
scombiner
- the aggregation function used to combine the items emitted by theObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatestDelayError
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T,@NonNull R> @NonNull Observable<R> combineLatestDelayError(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner, int bufferSize)
Combines anIterable
ofObservableSource
s by emitting an item that aggregates the latest values of each of theObservableSource
s each time an item is received from any of theObservableSource
s, where this aggregation is defined by a specified function and delays any error from the sources until all sourceObservableSource
s terminate.Note on method signature: since Java doesn't allow creating a generic array with
new T[]
, the implementation of this operator has to create anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.
If the provided iterable of
ObservableSource
s is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.- Scheduler:
combineLatestDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base type of source valuesR
- the result type- Parameters:
sources
- the collection of sourceObservableSource
scombiner
- the aggregation function used to combine the items emitted by theObservableSource
sbufferSize
- the expected number of row combination items to be buffered internally- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
orcombiner
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: CombineLatest
-
concat
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> concat(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
Concatenates elements of eachObservableSource
provided via anIterable
sequence into a single sequence of elements without interleaving them.- Scheduler:
concat
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common value type of the sources- Parameters:
sources
- theIterable
sequence ofObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
-
concat
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> concat(@NonNull @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
Returns anObservable
that emits the items emitted by each of theObservableSource
s emitted by theObservableSource
, one after the other, without interleaving them.- Scheduler:
concat
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- anObservableSource
that emitsObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Concat
-
concat
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> concat(@NonNull @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources, int bufferSize)
Returns anObservable
that emits the items emitted by each of theObservableSource
s emitted by the outerObservableSource
, one after the other, without interleaving them.- Scheduler:
concat
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- anObservableSource
that emitsObservableSource
sbufferSize
- the number of innerObservableSource
s expected to be buffered.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Concat
-
concat
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> concat(@NonNull @NonNull ObservableSource<? extends @NonNull T> source1, ObservableSource<? extends @NonNull T> source2)
Returns anObservable
that emits the items emitted by twoObservableSource
s, one after the other, without interleaving them.- Scheduler:
concat
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- anObservableSource
to be concatenatedsource2
- anObservableSource
to be concatenated- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
orsource2
isnull
- See Also:
- ReactiveX operators documentation: Concat
-
concat
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> concat(@NonNull @NonNull ObservableSource<? extends @NonNull T> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T> source3)
Returns anObservable
that emits the items emitted by threeObservableSource
s, one after the other, without interleaving them.- Scheduler:
concat
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- anObservableSource
to be concatenatedsource2
- anObservableSource
to be concatenatedsource3
- anObservableSource
to be concatenated- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orsource3
isnull
- See Also:
- ReactiveX operators documentation: Concat
-
concat
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> concat(@NonNull @NonNull ObservableSource<? extends @NonNull T> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T> source3, @NonNull @NonNull ObservableSource<? extends @NonNull T> source4)
Returns anObservable
that emits the items emitted by fourObservableSource
s, one after the other, without interleaving them.- Scheduler:
concat
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- anObservableSource
to be concatenatedsource2
- anObservableSource
to be concatenatedsource3
- anObservableSource
to be concatenatedsource4
- anObservableSource
to be concatenated- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
orsource4
isnull
- See Also:
- ReactiveX operators documentation: Concat
-
concatArray
@CheckReturnValue @SchedulerSupport("none") @NonNull @SafeVarargs public static <@NonNull T> @NonNull Observable<T> concatArray(@NonNull @NonNull ObservableSource<? extends @NonNull T>... sources)
Concatenates a variable number ofObservableSource
sources.Note: named this way because of overload conflict with
concat(ObservableSource<ObservableSource>)
- Scheduler:
concatArray
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base value type- Parameters:
sources
- the array of sources- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
-
concatArrayDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull @SafeVarargs public static <@NonNull T> @NonNull Observable<T> concatArrayDelayError(@NonNull @NonNull ObservableSource<? extends @NonNull T>... sources)
Concatenates a variable number ofObservableSource
sources and delays errors from any of them till all terminate.- Scheduler:
concatArrayDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base value type- Parameters:
sources
- the array of sources- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
-
concatArrayEager
@CheckReturnValue @SchedulerSupport("none") @SafeVarargs @NonNull public static <@NonNull T> @NonNull Observable<T> concatArrayEager(@NonNull @NonNull ObservableSource<? extends @NonNull T>... sources)
Concatenates an array ofObservableSource
s eagerly into a single stream of values.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
ObservableSource
s. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- an array ofObservableSource
s that need to be eagerly concatenated- Returns:
- the new
Observable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
- Since:
- 2.0
-
concatArrayEager
@CheckReturnValue @SchedulerSupport("none") @NonNull @SafeVarargs public static <@NonNull T> @NonNull Observable<T> concatArrayEager(int maxConcurrency, int bufferSize, @NonNull @NonNull ObservableSource<? extends @NonNull T>... sources)
Concatenates an array ofObservableSource
s eagerly into a single stream of values.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
ObservableSource
s. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- an array ofObservableSource
s that need to be eagerly concatenatedmaxConcurrency
- the maximum number of concurrent subscriptions at a time,Integer.MAX_VALUE
is interpreted as indication to subscribe to all sources at oncebufferSize
- the number of elements expected from eachObservableSource
to be buffered- Returns:
- the new
Observable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- Since:
- 2.0
-
concatArrayEagerDelayError
@CheckReturnValue @SchedulerSupport("none") @SafeVarargs @NonNull public static <@NonNull T> @NonNull Observable<T> concatArrayEagerDelayError(@NonNull @NonNull ObservableSource<? extends @NonNull T>... sources)
Concatenates an array ofObservableSource
s eagerly into a single stream of values and delaying any errors until all sources terminate.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
ObservableSource
s. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- an array ofObservableSource
s that need to be eagerly concatenated- Returns:
- the new
Observable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
- Since:
- 2.2.1 - experimental
-
concatArrayEagerDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull @SafeVarargs public static <@NonNull T> @NonNull Observable<T> concatArrayEagerDelayError(int maxConcurrency, int bufferSize, @NonNull @NonNull ObservableSource<? extends @NonNull T>... sources)
Concatenates an array ofObservableSource
s eagerly into a single stream of values and delaying any errors until all sources terminate.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
ObservableSource
s. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- an array ofObservableSource
s that need to be eagerly concatenatedmaxConcurrency
- the maximum number of concurrent subscriptions at a time,Integer.MAX_VALUE
is interpreted as indication to subscribe to all sources at oncebufferSize
- the number of elements expected from eachObservableSource
to be buffered- Returns:
- the new
Observable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- Since:
- 2.2.1 - experimental
-
concatDelayError
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> concatDelayError(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
Concatenates theIterable
sequence ofObservableSource
s into a singleObservable
sequence by subscribing to eachObservableSource
, one after the other, one at a time and delays any errors till the all innerObservableSource
s terminate.- Scheduler:
concatDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- theIterable
sequence ofObservableSource
s- Returns:
- the new
Observable
with the concatenating behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
-
concatDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> concatDelayError(@NonNull @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
Concatenates theObservableSource
sequence ofObservableSource
s into a singleObservable
sequence by subscribing to each innerObservableSource
, one after the other, one at a time and delays any errors till the all inner and the outerObservableSource
s terminate.- Scheduler:
concatDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- theObservableSource
sequence ofObservableSource
s- Returns:
- the new
Observable
with the concatenating behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
-
concatDelayError
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> concatDelayError(@NonNull @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources, int bufferSize, boolean tillTheEnd)
Concatenates theObservableSource
sequence ofObservableSource
s into a single sequence by subscribing to each innerObservableSource
, one after the other, one at a time and delays any errors till the all inner and the outerObservableSource
s terminate.- Scheduler:
concatDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- theObservableSource
sequence ofObservableSource
sbufferSize
- the number of innerObservableSource
s expected to be bufferedtillTheEnd
- iftrue
, exceptions from the outer and all innerObservableSource
s are delayed to the end iffalse
, exception from the outerObservableSource
is delayed till the activeObservableSource
terminates- Returns:
- the new
Observable
with the concatenating behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive
-
concatEager
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> concatEager(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
Concatenates a sequence ofObservableSource
s eagerly into a single stream of values.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
ObservableSource
s. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- a sequence ofObservableSource
s that need to be eagerly concatenated- Returns:
- the new
Observable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
- Since:
- 2.0
-
concatEager
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> concatEager(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency, int bufferSize)
Concatenates a sequence ofObservableSource
s eagerly into a single stream of values and runs a limited number of inner sequences at once.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
ObservableSource
s. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- a sequence ofObservableSource
s that need to be eagerly concatenatedmaxConcurrency
- the maximum number of concurrently running innerObservableSource
s;Integer.MAX_VALUE
is interpreted as all innerObservableSource
s can be active at the same timebufferSize
- the number of elements expected from each innerObservableSource
to be buffered- Returns:
- the new
Observable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- Since:
- 2.0
-
concatEager
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> concatEager(@NonNull @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
Concatenates anObservableSource
sequence ofObservableSource
s eagerly into a single stream of values.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source
ObservableSource
s as they are observed. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- a sequence ofObservableSource
s that need to be eagerly concatenated- Returns:
- the new
Observable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
- Since:
- 2.0
-
concatEager
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> concatEager(@NonNull @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency, int bufferSize)
Concatenates anObservableSource
sequence ofObservableSource
s eagerly into a single stream of values and runs a limited number of inner sequences at once.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source
ObservableSource
s as they are observed. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- a sequence ofObservableSource
s that need to be eagerly concatenatedmaxConcurrency
- the maximum number of concurrently running innerObservableSource
s;Integer.MAX_VALUE
is interpreted as all innerObservableSource
s can be active at the same timebufferSize
- the number of innerObservableSource
expected to be buffered- Returns:
- the new
Observable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- Since:
- 2.0
-
concatEagerDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> concatEagerDelayError(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
Concatenates a sequence ofObservableSource
s eagerly into a single stream of values, delaying errors until all the inner sequences terminate.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
ObservableSource
s. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- a sequence ofObservableSource
s that need to be eagerly concatenated- Returns:
- the new
Observable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
- Since:
- 3.0.0
-
concatEagerDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> concatEagerDelayError(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency, int bufferSize)
Concatenates a sequence ofObservableSource
s eagerly into a single stream of values, delaying errors until all the inner sequences terminate and runs a limited number of inner sequences at once.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
ObservableSource
s. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- a sequence ofObservableSource
s that need to be eagerly concatenatedmaxConcurrency
- the maximum number of concurrently running innerObservableSource
s;Integer.MAX_VALUE
is interpreted as all innerObservableSource
s can be active at the same timebufferSize
- the number of elements expected from each innerObservableSource
to be buffered- Returns:
- the new
Observable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- Since:
- 3.0.0
-
concatEagerDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> concatEagerDelayError(@NonNull @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
Concatenates anObservableSource
sequence ofObservableSource
s eagerly into a single stream of values, delaying errors until all the inner and the outer sequence terminate.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source
ObservableSource
s as they are observed. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- a sequence ofObservableSource
s that need to be eagerly concatenated- Returns:
- the new
Observable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
- Since:
- 3.0.0
-
concatEagerDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> concatEagerDelayError(@NonNull @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency, int bufferSize)
Concatenates anObservableSource
sequence ofObservableSource
s eagerly into a single stream of values, delaying errors until all the inner and the outer sequence terminate and runs a limited number of inner sequences at once.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source
ObservableSource
s as they are observed. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- a sequence ofObservableSource
s that need to be eagerly concatenatedmaxConcurrency
- the maximum number of concurrently running innerObservableSource
s;Integer.MAX_VALUE
is interpreted as all innerObservableSource
s can be active at the same timebufferSize
- the number of innerObservableSource
expected to be buffered- Returns:
- the new
Observable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- Since:
- 3.0.0
-
create
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> create(@NonNull @NonNull ObservableOnSubscribe<@NonNull T> source)
Provides an API (via a coldObservable
) that bridges the reactive world with the callback-style world.Example:
Observable.<Event>create(emitter -> { Callback listener = new Callback() { @Override public void onEvent(Event e) { emitter.onNext(e); if (e.isLast()) { emitter.onComplete(); } } @Override public void onFailure(Exception e) { emitter.onError(e); } }; AutoCloseable c = api.someMethod(listener); emitter.setCancellable(c::close); });
Whenever an
Observer
subscribes to the returnedObservable
, the providedObservableOnSubscribe
callback is invoked with a fresh instance of anObservableEmitter
that will interact only with that specificObserver
. If thisObserver
disposes the flow (makingObservableEmitter.isDisposed()
returntrue
), other observers subscribed to the same returnedObservable
are not affected.You should call the
ObservableEmitter
'sonNext
,onError
andonComplete
methods in a serialized fashion. The rest of its methods are thread-safe.- Scheduler:
create
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the element type- Parameters:
source
- the emitter that is called when anObserver
subscribes to the returnedObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource
isnull
- See Also:
ObservableOnSubscribe
,ObservableEmitter
,Cancellable
-
defer
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> defer(@NonNull @NonNull Supplier<? extends @NonNull ObservableSource<? extends @NonNull T>> supplier)
Returns anObservable
that calls anObservableSource
factory to create anObservableSource
for each newObserver
that subscribes. That is, for each subscriber, the actualObservableSource
that subscriber observes is determined by the factory function.The
defer
operator allows you to defer or delay emitting items from anObservableSource
until such time as anObserver
subscribes to theObservableSource
. This allows anObserver
to easily obtain updates or a refreshed version of the sequence.- Scheduler:
defer
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of the items emitted by theObservableSource
- Parameters:
supplier
- theObservableSource
factory function to invoke for eachObserver
that subscribes to the resultingObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsupplier
isnull
- See Also:
- ReactiveX operators documentation: Defer
-
empty
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> empty()
Returns anObservable
that emits no items to theObserver
and immediately invokes itsonComplete
method.- Scheduler:
empty
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of the items (ostensibly) emitted by theObservable
- Returns:
- the shared
Observable
instance - See Also:
- ReactiveX operators documentation: Empty
-
error
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> error(@NonNull @NonNull Supplier<? extends @NonNull java.lang.Throwable> supplier)
Returns anObservable
that invokes anObserver
'sonError
method when theObserver
subscribes to it.- Scheduler:
error
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of the items (ostensibly) emitted by theObservable
- Parameters:
supplier
- aSupplier
factory to return aThrowable
for each individualObserver
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsupplier
isnull
- See Also:
- ReactiveX operators documentation: Throw
-
error
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> error(@NonNull @NonNull java.lang.Throwable throwable)
Returns anObservable
that invokes anObserver
'sonError
method when theObserver
subscribes to it.- Scheduler:
error
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of the items (ostensibly) emitted by theObservable
- Parameters:
throwable
- the particularThrowable
to pass toonError
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifthrowable
isnull
- See Also:
- ReactiveX operators documentation: Throw
-
fromAction
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> fromAction(@NonNull @NonNull Action action)
Returns anObservable
instance that runs the givenAction
for eachObserver
and emits either its exception or simply completes.- Scheduler:
fromAction
does not operate by default on a particularScheduler
.- Error handling:
- If the
Action
throws an exception, the respectiveThrowable
is delivered to the downstream viaObserver.onError(Throwable)
, except when the downstream has canceled the resultingObservable
source. In this latter case, theThrowable
is delivered to the global error handler viaRxJavaPlugins.onError(Throwable)
as anUndeliverableException
.
- Type Parameters:
T
- the target type- Parameters:
action
- theAction
to run for eachObserver
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifaction
isnull
- Since:
- 3.0.0
-
fromArray
@CheckReturnValue @SchedulerSupport("none") @NonNull @SafeVarargs public static <@NonNull T> @NonNull Observable<T> fromArray(@NonNull @NonNull T... items)
Converts an array into anObservableSource
that emits the items in the array.- Scheduler:
fromArray
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of items in the array and the type of items to be emitted by the resultingObservable
- Parameters:
items
- the array of elements- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitems
isnull
- See Also:
- ReactiveX operators documentation: From
-
fromCallable
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> fromCallable(@NonNull @NonNull java.util.concurrent.Callable<? extends @NonNull T> callable)
Returns anObservable
that, when an observer subscribes to it, invokes a function you specify and then emits the value returned from that function.This allows you to defer the execution of the function you specify until an observer subscribes to the
Observable
. That is to say, it makes the function "lazy."- Scheduler:
fromCallable
does not operate by default on a particularScheduler
.- Error handling:
- If the
Callable
throws an exception, the respectiveThrowable
is delivered to the downstream viaObserver.onError(Throwable)
, except when the downstream has disposed the currentObservable
source. In this latter case, theThrowable
is delivered to the global error handler viaRxJavaPlugins.onError(Throwable)
as anUndeliverableException
.
- Type Parameters:
T
- the type of the item returned by theCallable
and emitted by theObservable
- Parameters:
callable
- a function, the execution of which should be deferred;fromCallable
will invoke this function only when an observer subscribes to theObservable
thatfromCallable
returns- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifcallable
isnull
- Since:
- 2.0
- See Also:
defer(Supplier)
,fromSupplier(Supplier)
-
fromCompletable
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> fromCompletable(@NonNull @NonNull CompletableSource completableSource)
Wraps aCompletableSource
into anObservable
.- Scheduler:
fromCompletable
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the target type- Parameters:
completableSource
- theCompletableSource
to convert from- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifcompletableSource
isnull
-
fromFuture
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> fromFuture(@NonNull @NonNull java.util.concurrent.Future<? extends @NonNull T> future)
Converts aFuture
into anObservable
.The operator calls
Future.get()
, which is a blocking method, on the subscription thread. It is recommended applyingsubscribeOn(Scheduler)
to move this blocking wait to a background thread, and if theScheduler
supports it, interrupt the wait when the flow is disposed.Unlike 1.x, disposing the
Observable
won't cancel the future. If necessary, one can use composition to achieve the cancellation effect:futureObservableSource.doOnDispose(() -> future.cancel(true));
.Also note that this operator will consume a
CompletionStage
-basedFuture
subclass (such asCompletableFuture
) in a blocking manner as well. Use thefromCompletionStage(CompletionStage)
operator to convert and consume such sources in a non-blocking fashion instead.- Scheduler:
fromFuture
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of object that theFuture
returns, and also the type of item to be emitted by the resultingObservable
- Parameters:
future
- the sourceFuture
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- iffuture
isnull
- See Also:
- ReactiveX operators documentation: From,
fromCompletionStage(CompletionStage)
-
fromFuture
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> fromFuture(@NonNull @NonNull java.util.concurrent.Future<? extends @NonNull T> future, long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Converts aFuture
into anObservable
, with a timeout on theFuture
.The operator calls
Future.get(long, TimeUnit)
, which is a blocking method, on the subscription thread. It is recommended applyingsubscribeOn(Scheduler)
to move this blocking wait to a background thread, and if theScheduler
supports it, interrupt the wait when the flow is disposed.Unlike 1.x, disposing the
Observable
won't cancel the future. If necessary, one can use composition to achieve the cancellation effect:futureObservableSource.doOnDispose(() -> future.cancel(true));
.Also note that this operator will consume a
CompletionStage
-basedFuture
subclass (such asCompletableFuture
) in a blocking manner as well. Use thefromCompletionStage(CompletionStage)
operator to convert and consume such sources in a non-blocking fashion instead.- Scheduler:
fromFuture
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of object that theFuture
returns, and also the type of item to be emitted by the resultingObservable
- Parameters:
future
- the sourceFuture
timeout
- the maximum time to wait before callingget
unit
- theTimeUnit
of thetimeout
argument- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- iffuture
orunit
isnull
- See Also:
- ReactiveX operators documentation: From,
fromCompletionStage(CompletionStage)
-
fromIterable
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> fromIterable(@NonNull @NonNull java.lang.Iterable<? extends @NonNull T> source)
Converts anIterable
sequence into anObservable
that emits the items in the sequence.- Scheduler:
fromIterable
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of items in theIterable
sequence and the type of items to be emitted by the resultingObservable
- Parameters:
source
- the sourceIterable
sequence- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource
isnull
- See Also:
- ReactiveX operators documentation: From,
fromStream(Stream)
-
fromMaybe
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> fromMaybe(@NonNull @NonNull MaybeSource<@NonNull T> maybe)
Returns anObservable
instance that when subscribed to, subscribes to theMaybeSource
instance and emitsonSuccess
as a single item or forwards anyonComplete
oronError
signal.- Scheduler:
fromMaybe
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the value type of theMaybeSource
element- Parameters:
maybe
- theMaybeSource
instance to subscribe to, notnull
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmaybe
isnull
- Since:
- 3.0.0
-
fromPublisher
@BackpressureSupport(UNBOUNDED_IN) @CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> fromPublisher(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> publisher)
Converts an arbitrary Reactive StreamsPublisher
into anObservable
.The
Publisher
must follow the Reactive-Streams specification. Violating the specification may result in undefined behavior.If possible, use
create(ObservableOnSubscribe)
to create a source-likeObservable
instead.Note that even though
Publisher
appears to be a functional interface, it is not recommended to implement it through a lambda as the specification requires state management that is not achievable with a stateless lambda.- Backpressure:
- The source
publisher
is consumed in an unbounded fashion without applying any backpressure to it. - Scheduler:
fromPublisher
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the value type of the flow- Parameters:
publisher
- thePublisher
to convert- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifpublisher
isnull
- See Also:
create(ObservableOnSubscribe)
-
fromRunnable
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> fromRunnable(@NonNull @NonNull java.lang.Runnable run)
Returns anObservable
instance that runs the givenRunnable
for eachObserver
and emits either its unchecked exception or simply completes.If the code to be wrapped needs to throw a checked or more broader
Throwable
exception, that exception has to be converted to an unchecked exception by the wrapped code itself. Alternatively, use thefromAction(Action)
method which allows the wrapped code to throw anyThrowable
exception and will signal it to observers as-is.- Scheduler:
fromRunnable
does not operate by default on a particularScheduler
.- Error handling:
- If the
Runnable
throws an exception, the respectiveThrowable
is delivered to the downstream viaObserver.onError(Throwable)
, except when the downstream has canceled the resultingObservable
source. In this latter case, theThrowable
is delivered to the global error handler viaRxJavaPlugins.onError(Throwable)
as anUndeliverableException
.
- Type Parameters:
T
- the target type- Parameters:
run
- theRunnable
to run for eachObserver
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifrun
isnull
- Since:
- 3.0.0
- See Also:
fromAction(Action)
-
fromSingle
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> fromSingle(@NonNull @NonNull SingleSource<@NonNull T> source)
Returns anObservable
instance that when subscribed to, subscribes to theSingleSource
instance and emitsonSuccess
as a single item or forwards theonError
signal.- Scheduler:
fromSingle
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the value type of theSingleSource
element- Parameters:
source
- theSingleSource
instance to subscribe to, notnull
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource
isnull
- Since:
- 3.0.0
-
fromSupplier
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> fromSupplier(@NonNull @NonNull Supplier<? extends @NonNull T> supplier)
Returns anObservable
that, when an observer subscribes to it, invokes a supplier function you specify and then emits the value returned from that function.This allows you to defer the execution of the function you specify until an observer subscribes to the
Observable
. That is to say, it makes the function "lazy."- Scheduler:
fromSupplier
does not operate by default on a particularScheduler
.- Error handling:
- If the
Supplier
throws an exception, the respectiveThrowable
is delivered to the downstream viaObserver.onError(Throwable)
, except when the downstream has disposed the currentObservable
source. In this latter case, theThrowable
is delivered to the global error handler viaRxJavaPlugins.onError(Throwable)
as anUndeliverableException
.
- Type Parameters:
T
- the type of the item emitted by theObservable
- Parameters:
supplier
- a function, the execution of which should be deferred;fromSupplier
will invoke this function only when an observer subscribes to theObservable
thatfromSupplier
returns- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsupplier
isnull
- Since:
- 3.0.0
- See Also:
defer(Supplier)
,fromCallable(Callable)
-
generate
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> generate(@NonNull @NonNull Consumer<Emitter<@NonNull T>> generator)
Returns a cold, synchronous and stateless generator of values.Note that the
Emitter.onNext(T)
,Emitter.onError(java.lang.Throwable)
andEmitter.onComplete()
methods provided to the function via theEmitter
instance should be called synchronously, never concurrently and only while the function body is executing. Calling them from multiple threads or outside the function call is not supported and leads to an undefined behavior.- Scheduler:
generate
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the generated value type- Parameters:
generator
- theConsumer
called in a loop after a downstreamObserver
has subscribed. The callback then should callonNext
,onError
oronComplete
to signal a value or a terminal event. Signaling multipleonNext
in a call will make the operator signalIllegalStateException
.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifgenerator
isnull
-
generate
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T,@NonNull S> @NonNull Observable<T> generate(@NonNull @NonNull Supplier<@NonNull S> initialState, @NonNull @NonNull BiConsumer<@NonNull S,Emitter<@NonNull T>> generator)
Returns a cold, synchronous and stateful generator of values.Note that the
Emitter.onNext(T)
,Emitter.onError(java.lang.Throwable)
andEmitter.onComplete()
methods provided to the function via theEmitter
instance should be called synchronously, never concurrently and only while the function body is executing. Calling them from multiple threads or outside the function call is not supported and leads to an undefined behavior.- Scheduler:
generate
does not operate by default on a particularScheduler
.
- Type Parameters:
S
- the type of the per-Observer
stateT
- the generated value type- Parameters:
initialState
- theSupplier
to generate the initial state for eachObserver
generator
- theBiConsumer
called in a loop after a downstreamObserver
has subscribed. The callback then should callonNext
,onError
oronComplete
to signal a value or a terminal event. Signaling multipleonNext
in a call will make the operator signalIllegalStateException
.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifinitialState
orgenerator
isnull
-
generate
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T,@NonNull S> @NonNull Observable<T> generate(@NonNull @NonNull Supplier<@NonNull S> initialState, @NonNull @NonNull BiConsumer<@NonNull S,Emitter<@NonNull T>> generator, @NonNull @NonNull Consumer<? super @NonNull S> disposeState)
Returns a cold, synchronous and stateful generator of values.Note that the
Emitter.onNext(T)
,Emitter.onError(java.lang.Throwable)
andEmitter.onComplete()
methods provided to the function via theEmitter
instance should be called synchronously, never concurrently and only while the function body is executing. Calling them from multiple threads or outside the function call is not supported and leads to an undefined behavior.- Scheduler:
generate
does not operate by default on a particularScheduler
.
- Type Parameters:
S
- the type of the per-Observer
stateT
- the generated value type- Parameters:
initialState
- theSupplier
to generate the initial state for eachObserver
generator
- theBiConsumer
called in a loop after a downstreamObserver
has subscribed. The callback then should callonNext
,onError
oronComplete
to signal a value or a terminal event. Signaling multipleonNext
in a call will make the operator signalIllegalStateException
.disposeState
- theConsumer
that is called with the current state when the generator terminates the sequence or it gets disposed- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifinitialState
,generator
ordisposeState
isnull
-
generate
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T,@NonNull S> @NonNull Observable<T> generate(@NonNull @NonNull Supplier<@NonNull S> initialState, @NonNull @NonNull BiFunction<@NonNull S,Emitter<@NonNull T>,@NonNull S> generator)
Returns a cold, synchronous and stateful generator of values.Note that the
Emitter.onNext(T)
,Emitter.onError(java.lang.Throwable)
andEmitter.onComplete()
methods provided to the function via theEmitter
instance should be called synchronously, never concurrently and only while the function body is executing. Calling them from multiple threads or outside the function call is not supported and leads to an undefined behavior.- Scheduler:
generate
does not operate by default on a particularScheduler
.
- Type Parameters:
S
- the type of the per-Observer
stateT
- the generated value type- Parameters:
initialState
- theSupplier
to generate the initial state for eachObserver
generator
- theBiConsumer
called in a loop after a downstreamObserver
has subscribed. The callback then should callonNext
,onError
oronComplete
to signal a value or a terminal event and should return a (new) state for the next invocation. Signaling multipleonNext
in a call will make the operator signalIllegalStateException
.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifinitialState
orgenerator
isnull
-
generate
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T,@NonNull S> @NonNull Observable<T> generate(@NonNull @NonNull Supplier<@NonNull S> initialState, @NonNull @NonNull BiFunction<@NonNull S,Emitter<@NonNull T>,@NonNull S> generator, @NonNull @NonNull Consumer<? super @NonNull S> disposeState)
Returns a cold, synchronous and stateful generator of values.Note that the
Emitter.onNext(T)
,Emitter.onError(java.lang.Throwable)
andEmitter.onComplete()
methods provided to the function via theEmitter
instance should be called synchronously, never concurrently and only while the function body is executing. Calling them from multiple threads or outside the function call is not supported and leads to an undefined behavior.- Scheduler:
generate
does not operate by default on a particularScheduler
.
- Type Parameters:
S
- the type of the per-Observer
stateT
- the generated value type- Parameters:
initialState
- theSupplier
to generate the initial state for eachObserver
generator
- theBiConsumer
called in a loop after a downstreamObserver
has subscribed. The callback then should callonNext
,onError
oronComplete
to signal a value or a terminal event and should return a (new) state for the next invocation. Signaling multipleonNext
in a call will make the operator signalIllegalStateException
.disposeState
- theConsumer
that is called with the current state when the generator terminates the sequence or it gets disposed- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifinitialState
,generator
ordisposeState
isnull
-
interval
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public static @NonNull Observable<java.lang.Long> interval(long initialDelay, long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits a0L
after theinitialDelay
and ever increasing numbers after eachperiod
of time thereafter.- Scheduler:
interval
operates by default on thecomputation
Scheduler
.
- Parameters:
initialDelay
- the initial delay time to wait before emitting the first value of 0Lperiod
- the period of time between emissions of the subsequent numbersunit
- the time unit for bothinitialDelay
andperiod
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- Since:
- 1.0.12
- See Also:
- ReactiveX operators documentation: Interval
-
interval
@CheckReturnValue @NonNull @SchedulerSupport("custom") public static @NonNull Observable<java.lang.Long> interval(long initialDelay, long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits a0L
after theinitialDelay
and ever increasing numbers after eachperiod
of time thereafter, on a specifiedScheduler
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
initialDelay
- the initial delay time to wait before emitting the first value of 0Lperiod
- the period of time between emissions of the subsequent numbersunit
- the time unit for bothinitialDelay
andperiod
scheduler
- theScheduler
on which the waiting happens and items are emitted- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- Since:
- 1.0.12
- See Also:
- ReactiveX operators documentation: Interval
-
interval
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public static @NonNull Observable<java.lang.Long> interval(long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits a sequential number every specified interval of time.- Scheduler:
interval
operates by default on thecomputation
Scheduler
.
- Parameters:
period
- the period size in time units (see below)unit
- time units to use for the interval size- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Interval
-
interval
@CheckReturnValue @SchedulerSupport("custom") @NonNull public static @NonNull Observable<java.lang.Long> interval(long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits a sequential number every specified interval of time, on a specifiedScheduler
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
period
- the period size in time units (see below)unit
- time units to use for the interval sizescheduler
- theScheduler
to use for scheduling the items- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Interval
-
intervalRange
@CheckReturnValue @NonNull @SchedulerSupport("io.reactivex:computation") public static @NonNull Observable<java.lang.Long> intervalRange(long start, long count, long initialDelay, long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Signals a range of long values, the first after some initial delay and the rest periodically after.The sequence completes immediately after the last value (start + count - 1) has been reached.
- Scheduler:
intervalRange
by default operates on thecomputation
Scheduler
.
- Parameters:
start
- that start value of the rangecount
- the number of values to emit in total, if zero, the operator emits anonComplete
after the initial delay.initialDelay
- the initial delay before signaling the first value (the start)period
- the period between subsequent valuesunit
- the unit of measure of theinitialDelay
andperiod
amounts- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
java.lang.IllegalArgumentException
- ifcount
is negative, or ifstart
+count
− 1 exceedsLong.MAX_VALUE
- See Also:
range(int, int)
-
intervalRange
@CheckReturnValue @NonNull @SchedulerSupport("custom") public static @NonNull Observable<java.lang.Long> intervalRange(long start, long count, long initialDelay, long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Signals a range of long values, the first after some initial delay and the rest periodically after.The sequence completes immediately after the last value (start + count - 1) has been reached.
*
- Scheduler:
- you provide the
Scheduler
.
- Parameters:
start
- that start value of the rangecount
- the number of values to emit in total, if zero, the operator emits anonComplete
after the initial delay.initialDelay
- the initial delay before signaling the first value (the start)period
- the period between subsequent valuesunit
- the unit of measure of theinitialDelay
andperiod
amountsscheduler
- the target scheduler where the values and terminal signals will be emitted- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifcount
is negative, or ifstart
+count
− 1 exceedsLong.MAX_VALUE
-
just
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> just(@NonNull @NonNull T item)
Returns anObservable
that signals the given (constant reference) item and then completes.Note that the item is taken and re-emitted as is and not computed by any means by
just
. UsefromCallable(Callable)
to generate a single item on demand (whenObserver
s subscribe to it).See the multi-parameter overloads of
just
to emit more than one (constant reference) items one after the other. UsefromArray(Object...)
to emit an arbitrary number of items that are known upfront.To emit the items of an
Iterable
sequence (such as aList
), usefromIterable(Iterable)
.- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of that item- Parameters:
item
- the item to emit- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitem
isnull
- See Also:
- ReactiveX operators documentation: Just,
just(Object, Object)
,fromCallable(Callable)
,fromArray(Object...)
,fromIterable(Iterable)
-
just
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> just(@NonNull @NonNull T item1, @NonNull @NonNull T item2)
Converts two items into anObservable
that emits those items.- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second item- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitem1
oritem2
isnull
- See Also:
- ReactiveX operators documentation: Just
-
just
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> just(@NonNull @NonNull T item1, @NonNull @NonNull T item2, @NonNull @NonNull T item3)
Converts three items into anObservable
that emits those items.- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second itemitem3
- third item- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitem1
,item2
oritem3
isnull
- See Also:
- ReactiveX operators documentation: Just
-
just
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> just(@NonNull @NonNull T item1, @NonNull @NonNull T item2, @NonNull @NonNull T item3, @NonNull @NonNull T item4)
Converts four items into anObservable
that emits those items.- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth item- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitem1
,item2
,item3
oritem4
isnull
- See Also:
- ReactiveX operators documentation: Just
-
just
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> just(@NonNull @NonNull T item1, @NonNull @NonNull T item2, @NonNull @NonNull T item3, @NonNull @NonNull T item4, @NonNull @NonNull T item5)
Converts five items into anObservable
that emits those items.- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth item- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitem1
,item2
,item3
,item4
oritem5
isnull
- See Also:
- ReactiveX operators documentation: Just
-
just
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> just(@NonNull @NonNull T item1, @NonNull @NonNull T item2, @NonNull @NonNull T item3, @NonNull @NonNull T item4, @NonNull @NonNull T item5, @NonNull @NonNull T item6)
Converts six items into anObservable
that emits those items.- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth itemitem6
- sixth item- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitem1
,item2
,item3
,item4
,item5
oritem6
isnull
- See Also:
- ReactiveX operators documentation: Just
-
just
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> just(@NonNull @NonNull T item1, @NonNull @NonNull T item2, @NonNull @NonNull T item3, @NonNull @NonNull T item4, @NonNull @NonNull T item5, @NonNull @NonNull T item6, @NonNull @NonNull T item7)
Converts seven items into anObservable
that emits those items.- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth itemitem6
- sixth itemitem7
- seventh item- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitem1
,item2
,item3
,item4
,item5
,item6
oritem7
isnull
- See Also:
- ReactiveX operators documentation: Just
-
just
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> just(@NonNull @NonNull T item1, @NonNull @NonNull T item2, @NonNull @NonNull T item3, @NonNull @NonNull T item4, @NonNull @NonNull T item5, @NonNull @NonNull T item6, @NonNull @NonNull T item7, @NonNull @NonNull T item8)
Converts eight items into anObservable
that emits those items.- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth itemitem6
- sixth itemitem7
- seventh itemitem8
- eighth item- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitem1
,item2
,item3
,item4
,item5
,item6
item7
oritem8
isnull
- See Also:
- ReactiveX operators documentation: Just
-
just
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> just(@NonNull @NonNull T item1, @NonNull @NonNull T item2, @NonNull @NonNull T item3, @NonNull @NonNull T item4, @NonNull @NonNull T item5, @NonNull @NonNull T item6, @NonNull @NonNull T item7, @NonNull @NonNull T item8, @NonNull @NonNull T item9)
Converts nine items into anObservable
that emits those items.- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth itemitem6
- sixth itemitem7
- seventh itemitem8
- eighth itemitem9
- ninth item- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitem1
,item2
,item3
,item4
,item5
,item6
item7
,item8
oritem9
isnull
- See Also:
- ReactiveX operators documentation: Just
-
just
@CheckReturnValue @NonNull @SchedulerSupport("none") public static <@NonNull T> @NonNull Observable<T> just(@NonNull @NonNull T item1, @NonNull @NonNull T item2, @NonNull @NonNull T item3, @NonNull @NonNull T item4, @NonNull @NonNull T item5, @NonNull @NonNull T item6, @NonNull @NonNull T item7, @NonNull @NonNull T item8, @NonNull @NonNull T item9, @NonNull @NonNull T item10)
Converts ten items into anObservable
that emits those items.- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth itemitem6
- sixth itemitem7
- seventh itemitem8
- eighth itemitem9
- ninth itemitem10
- tenth item- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitem1
,item2
,item3
,item4
,item5
,item6
item7
,item8
,item9
oritem10
isnull
- See Also:
- ReactiveX operators documentation: Just
-
merge
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> merge(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency, int bufferSize)
Flattens anIterable
ofObservableSource
s into oneObservable
, without any transformation, while limiting the number of concurrent subscriptions to theseObservableSource
s.You can combine the items emitted by multiple
ObservableSource
s so that they appear as a singleObservableSource
, by using themerge
method.- Scheduler:
merge
does not operate by default on a particularScheduler
.- Error handling:
- If any of the returned
ObservableSource
s signal aThrowable
viaonError
, the resultingObservable
terminates with thatThrowable
and all other sourceObservableSource
s are disposed. If more than oneObservableSource
signals an error, the resultingObservable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedObservable
has been disposed or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Iterable, int, int)
to merge sources and terminate only when all sourceObservableSource
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- theIterable
ofObservableSource
smaxConcurrency
- the maximum number ofObservableSource
s that may be subscribed to concurrentlybufferSize
- the number of items expected from each innerObservableSource
to be buffered- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(Iterable, int, int)
-
mergeArray
@CheckReturnValue @SchedulerSupport("none") @NonNull @SafeVarargs public static <@NonNull T> @NonNull Observable<T> mergeArray(int maxConcurrency, int bufferSize, @NonNull @NonNull ObservableSource<? extends @NonNull T>... sources)
Flattens an array ofObservableSource
s into oneObservable
, without any transformation, while limiting the number of concurrent subscriptions to theseObservableSource
s.You can combine the items emitted by multiple
ObservableSource
s so that they appear as a singleObservableSource
, by using themerge
method.- Scheduler:
mergeArray
does not operate by default on a particularScheduler
.- Error handling:
- If any of the
ObservableSource
s signal aThrowable
viaonError
, the resultingObservable
terminates with thatThrowable
and all other sourceObservableSource
s are disposed. If more than oneObservableSource
signals an error, the resultingObservable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedObservable
has been disposed or terminated with a (composite) error will be sent to the same global error handler. UsemergeArrayDelayError(int, int, ObservableSource...)
to merge sources and terminate only when all sourceObservableSource
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- the array ofObservableSource
smaxConcurrency
- the maximum number ofObservableSource
s that may be subscribed to concurrentlybufferSize
- the number of items expected from each innerObservableSource
to be buffered- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Merge,
mergeArrayDelayError(int, int, ObservableSource...)
-
merge
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> merge(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
Flattens anIterable
ofObservableSource
s into oneObservable
, without any transformation.You can combine the items emitted by multiple
ObservableSource
s so that they appear as a singleObservableSource
, by using themerge
method.- Scheduler:
merge
does not operate by default on a particularScheduler
.- Error handling:
- If any of the returned
ObservableSource
s signal aThrowable
viaonError
, the resultingObservable
terminates with thatThrowable
and all other sourceObservableSource
s are disposed. If more than oneObservableSource
signals an error, the resultingObservable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedObservable
has been disposed or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Iterable)
to merge sources and terminate only when all sourceObservableSource
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- theIterable
ofObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(Iterable)
-
merge
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> merge(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency)
Flattens anIterable
ofObservableSource
s into oneObservable
, without any transformation, while limiting the number of concurrent subscriptions to theseObservableSource
s.You can combine the items emitted by multiple
ObservableSource
s so that they appear as a singleObservableSource
, by using themerge
method.- Scheduler:
merge
does not operate by default on a particularScheduler
.- Error handling:
- If any of the returned
ObservableSource
s signal aThrowable
viaonError
, the resultingObservable
terminates with thatThrowable
and all other sourceObservableSource
s are disposed. If more than oneObservableSource
signals an error, the resultingObservable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedObservable
has been disposed or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Iterable, int)
to merge sources and terminate only when all sourceObservableSource
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- theIterable
ofObservableSource
smaxConcurrency
- the maximum number ofObservableSource
s that may be subscribed to concurrently- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is less than or equal to 0- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(Iterable, int)
-
merge
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> merge(@NonNull @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
Flattens anObservableSource
that emitsObservableSource
s into a singleObservable
that emits the items emitted by thoseObservableSource
s, without any transformation.You can combine the items emitted by multiple
ObservableSource
s so that they appear as a singleObservableSource
, by using themerge
method.- Scheduler:
merge
does not operate by default on a particularScheduler
.- Error handling:
- If any of the returned
ObservableSource
s signal aThrowable
viaonError
, the resultingObservable
terminates with thatThrowable
and all other sourceObservableSource
s are disposed. If more than oneObservableSource
signals an error, the resultingObservable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedObservable
has been disposed or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(ObservableSource)
to merge sources and terminate only when all sourceObservableSource
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- anObservableSource
that emitsObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(ObservableSource)
-
merge
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> merge(@NonNull @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency)
Flattens anObservableSource
that emitsObservableSource
s into a singleObservable
that emits the items emitted by thoseObservableSource
s, without any transformation, while limiting the maximum number of concurrent subscriptions to theseObservableSource
s.You can combine the items emitted by multiple
ObservableSource
s so that they appear as a singleObservableSource
, by using themerge
method.- Scheduler:
merge
does not operate by default on a particularScheduler
.- Error handling:
- If any of the returned
ObservableSource
s signal aThrowable
viaonError
, the resultingObservable
terminates with thatThrowable
and all other sourceObservableSource
s are disposed. If more than oneObservableSource
signals an error, the resultingObservable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedObservable
has been disposed or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(ObservableSource, int)
to merge sources and terminate only when all sourceObservableSource
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- anObservableSource
that emitsObservableSource
smaxConcurrency
- the maximum number ofObservableSource
s that may be subscribed to concurrently- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive- Since:
- 1.1.0
- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(ObservableSource, int)
-
merge
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> merge(@NonNull @NonNull ObservableSource<? extends @NonNull T> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T> source2)
Flattens twoObservableSource
s into a singleObservable
, without any transformation.You can combine items emitted by multiple
ObservableSource
s so that they appear as a singleObservableSource
, by using themerge
method.- Scheduler:
merge
does not operate by default on a particularScheduler
.- Error handling:
- If any of the
ObservableSource
s signal aThrowable
viaonError
, the resultingObservable
terminates with thatThrowable
and all other sourceObservableSource
s are disposed. If more than oneObservableSource
signals an error, the resultingObservable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedObservable
has been disposed or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(ObservableSource, ObservableSource)
to merge sources and terminate only when all sourceObservableSource
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- anObservableSource
to be mergedsource2
- anObservableSource
to be merged- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
orsource2
isnull
- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(ObservableSource, ObservableSource)
-
merge
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> merge(@NonNull @NonNull ObservableSource<? extends @NonNull T> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T> source3)
Flattens threeObservableSource
s into a singleObservable
, without any transformation.You can combine items emitted by multiple
ObservableSource
s so that they appear as a singleObservableSource
, by using themerge
method.- Scheduler:
merge
does not operate by default on a particularScheduler
.- Error handling:
- If any of the
ObservableSource
s signal aThrowable
viaonError
, the resultingObservable
terminates with thatThrowable
and all other sourceObservableSource
s are disposed. If more than oneObservableSource
signals an error, the resultingObservable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedObservable
has been disposed or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(ObservableSource, ObservableSource, ObservableSource)
to merge sources and terminate only when all sourceObservableSource
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- anObservableSource
to be mergedsource2
- anObservableSource
to be mergedsource3
- anObservableSource
to be merged- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orsource3
isnull
- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(ObservableSource, ObservableSource, ObservableSource)
-
merge
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> merge(@NonNull @NonNull ObservableSource<? extends @NonNull T> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T> source3, @NonNull @NonNull ObservableSource<? extends @NonNull T> source4)
Flattens fourObservableSource
s into a singleObservable
, without any transformation.You can combine items emitted by multiple
ObservableSource
s so that they appear as a singleObservableSource
, by using themerge
method.- Scheduler:
merge
does not operate by default on a particularScheduler
.- Error handling:
- If any of the
ObservableSource
s signal aThrowable
viaonError
, the resultingObservable
terminates with thatThrowable
and all other sourceObservableSource
s are disposed. If more than oneObservableSource
signals an error, the resultingObservable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedObservable
has been disposed or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(ObservableSource, ObservableSource, ObservableSource, ObservableSource)
to merge sources and terminate only when all sourceObservableSource
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- anObservableSource
to be mergedsource2
- anObservableSource
to be mergedsource3
- anObservableSource
to be mergedsource4
- anObservableSource
to be merged- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
orsource4
isnull
- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(ObservableSource, ObservableSource, ObservableSource, ObservableSource)
-
mergeArray
@CheckReturnValue @SchedulerSupport("none") @NonNull @SafeVarargs public static <@NonNull T> @NonNull Observable<T> mergeArray(@NonNull @NonNull ObservableSource<? extends @NonNull T>... sources)
Flattens an array ofObservableSource
s into oneObservable
, without any transformation.You can combine items emitted by multiple
ObservableSource
s so that they appear as a singleObservableSource
, by using themerge
method.- Scheduler:
mergeArray
does not operate by default on a particularScheduler
.- Error handling:
- If any of the
ObservableSource
s signal aThrowable
viaonError
, the resultingObservable
terminates with thatThrowable
and all other sourceObservableSource
s are disposed. If more than oneObservableSource
signals an error, the resultingObservable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedObservable
has been disposed or terminated with a (composite) error will be sent to the same global error handler. UsemergeArrayDelayError(ObservableSource...)
to merge sources and terminate only when all sourceObservableSource
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- the array ofObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Merge,
mergeArrayDelayError(ObservableSource...)
-
mergeDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> mergeDelayError(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
Flattens anIterable
ofObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from each of the returnedObservableSource
s without being interrupted by an error notification from one of them.This behaves like
merge(ObservableSource)
except that if any of the mergedObservableSource
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedObservableSource
s have finished emitting items.Even if multiple merged
ObservableSource
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsObserver
s once.- Scheduler:
mergeDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- theIterable
ofObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> mergeDelayError(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency, int bufferSize)
Flattens anIterable
ofObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from each of the returnedObservableSource
s without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to theseObservableSource
s.This behaves like
merge(ObservableSource)
except that if any of the mergedObservableSource
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedObservableSource
s have finished emitting items.Even if multiple merged
ObservableSource
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsObserver
s once.- Scheduler:
mergeDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- theIterable
ofObservableSource
smaxConcurrency
- the maximum number ofObservableSource
s that may be subscribed to concurrentlybufferSize
- the number of items expected from each innerObservableSource
to be buffered- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Merge
-
mergeArrayDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull @SafeVarargs public static <@NonNull T> @NonNull Observable<T> mergeArrayDelayError(int maxConcurrency, int bufferSize, @NonNull @NonNull ObservableSource<? extends @NonNull T>... sources)
Flattens an array ofObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from each of theObservableSource
s without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to theseObservableSource
s.This behaves like
merge(ObservableSource)
except that if any of the mergedObservableSource
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedObservableSource
s have finished emitting items.Even if multiple merged
ObservableSource
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsObserver
s once.- Scheduler:
mergeArrayDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- the array ofObservableSource
smaxConcurrency
- the maximum number ofObservableSource
s that may be subscribed to concurrentlybufferSize
- the number of items expected from each innerObservableSource
to be buffered- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> mergeDelayError(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency)
Flattens anIterable
ofObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from each of the returnedObservableSource
s without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to theseObservableSource
s.This behaves like
merge(ObservableSource)
except that if any of the mergedObservableSource
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedObservableSource
s have finished emitting items.Even if multiple merged
ObservableSource
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsObserver
s once.- Scheduler:
mergeDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- theIterable
ofObservableSource
smaxConcurrency
- the maximum number ofObservableSource
s that may be subscribed to concurrently- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> mergeDelayError(@NonNull @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
Flattens anObservableSource
that emitsObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from all of the emittedObservableSource
s without being interrupted by an error notification from one of them.This behaves like
merge(ObservableSource)
except that if any of the mergedObservableSource
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedObservableSource
s have finished emitting items.Even if multiple merged
ObservableSource
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsObserver
s once.- Scheduler:
mergeDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- anObservableSource
that emitsObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> mergeDelayError(@NonNull @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources, int maxConcurrency)
Flattens anObservableSource
that emitsObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from all of the emittedObservableSource
s without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to theseObservableSource
s.This behaves like
merge(ObservableSource)
except that if any of the mergedObservableSource
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedObservableSource
s have finished emitting items.Even if multiple merged
ObservableSource
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsObserver
s once.- Scheduler:
mergeDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- anObservableSource
that emitsObservableSource
smaxConcurrency
- the maximum number ofObservableSource
s that may be subscribed to concurrently- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> mergeDelayError(@NonNull @NonNull ObservableSource<? extends @NonNull T> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T> source2)
Flattens twoObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from each of theObservableSource
s without being interrupted by an error notification from one of them.This behaves like
merge(ObservableSource, ObservableSource)
except that if any of the mergedObservableSource
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedObservableSource
s have finished emitting items.Even if both merged
ObservableSource
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsObserver
s once.- Scheduler:
mergeDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- anObservableSource
to be mergedsource2
- anObservableSource
to be merged- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
orsource2
isnull
- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> mergeDelayError(@NonNull @NonNull ObservableSource<? extends @NonNull T> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T> source3)
Flattens threeObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from all of theObservableSource
s without being interrupted by an error notification from one of them.This behaves like
merge(ObservableSource, ObservableSource, ObservableSource)
except that if any of the mergedObservableSource
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedObservableSource
s have finished emitting items.Even if multiple merged
ObservableSource
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsObserver
s once.- Scheduler:
mergeDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- anObservableSource
to be mergedsource2
- anObservableSource
to be mergedsource3
- anObservableSource
to be merged- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orsource3
isnull
- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> mergeDelayError(@NonNull @NonNull ObservableSource<? extends @NonNull T> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T> source3, @NonNull @NonNull ObservableSource<? extends @NonNull T> source4)
Flattens fourObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from all of theObservableSource
s without being interrupted by an error notification from one of them.This behaves like
merge(ObservableSource, ObservableSource, ObservableSource, ObservableSource)
except that if any of the mergedObservableSource
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedObservableSource
s have finished emitting items.Even if multiple merged
ObservableSource
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsObserver
s once.- Scheduler:
mergeDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- anObservableSource
to be mergedsource2
- anObservableSource
to be mergedsource3
- anObservableSource
to be mergedsource4
- anObservableSource
to be merged- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
orsource4
isnull
- See Also:
- ReactiveX operators documentation: Merge
-
mergeArrayDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull @SafeVarargs public static <@NonNull T> @NonNull Observable<T> mergeArrayDelayError(@NonNull @NonNull ObservableSource<? extends @NonNull T>... sources)
Flattens an array ofObservableSource
s into oneObservable
, in a way that allows anObserver
to receive all successfully emitted items from each of theObservableSource
s without being interrupted by an error notification from one of them.This behaves like
merge(ObservableSource)
except that if any of the mergedObservableSource
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedObservableSource
s have finished emitting items.Even if multiple merged
ObservableSource
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsObserver
s once.- Scheduler:
mergeArrayDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- the array ofObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Merge
-
never
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> never()
Returns anObservable
that never sends any items or notifications to anObserver
.The returned
Observable
is useful primarily for testing purposes.- Scheduler:
never
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of items (not) emitted by theObservable
- Returns:
- the shared
Observable
instance - See Also:
- ReactiveX operators documentation: Never
-
range
@CheckReturnValue @SchedulerSupport("none") @NonNull public static @NonNull Observable<java.lang.Integer> range(int start, int count)
Returns anObservable
that emits a sequence ofInteger
s within a specified range.- Scheduler:
range
does not operate by default on a particularScheduler
.
- Parameters:
start
- the value of the firstInteger
in the sequencecount
- the number of sequentialInteger
s to generate- Returns:
- the new
Observable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
is negative, or ifstart
+count
− 1 exceedsInteger.MAX_VALUE
- See Also:
- ReactiveX operators documentation: Range,
rangeLong(long, long)
,intervalRange(long, long, long, long, TimeUnit)
-
rangeLong
@CheckReturnValue @SchedulerSupport("none") @NonNull public static @NonNull Observable<java.lang.Long> rangeLong(long start, long count)
Returns anObservable
that emits a sequence ofLong
s within a specified range.- Scheduler:
rangeLong
does not operate by default on a particularScheduler
.
- Parameters:
start
- the value of the firstLong
in the sequencecount
- the number of sequentialLong
s to generate- Returns:
- the new
Observable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
is negative, or ifstart
+count
− 1 exceedsLong.MAX_VALUE
- See Also:
- ReactiveX operators documentation: Range,
intervalRange(long, long, long, long, TimeUnit)
-
sequenceEqual
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Single<java.lang.Boolean> sequenceEqual(@NonNull @NonNull ObservableSource<? extends @NonNull T> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T> source2)
Returns aSingle
that emits aBoolean
value that indicates whether twoObservableSource
sequences are the same by comparing the items emitted by eachObservableSource
pairwise.- Scheduler:
sequenceEqual
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of items emitted by eachObservableSource
- Parameters:
source1
- the firstObservableSource
to comparesource2
- the secondObservableSource
to compare- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifsource1
orsource2
isnull
- See Also:
- ReactiveX operators documentation: SequenceEqual
-
sequenceEqual
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Single<java.lang.Boolean> sequenceEqual(@NonNull @NonNull ObservableSource<? extends @NonNull T> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T> source2, @NonNull @NonNull BiPredicate<? super @NonNull T,? super @NonNull T> isEqual)
Returns aSingle
that emits aBoolean
value that indicates whether twoObservableSource
sequences are the same by comparing the items emitted by eachObservableSource
pairwise based on the results of a specified equality function.- Scheduler:
sequenceEqual
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of items emitted by eachObservableSource
- Parameters:
source1
- the firstObservableSource
to comparesource2
- the secondObservableSource
to compareisEqual
- a function used to compare items emitted by eachObservableSource
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orisEqual
isnull
- See Also:
- ReactiveX operators documentation: SequenceEqual
-
sequenceEqual
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Single<java.lang.Boolean> sequenceEqual(@NonNull @NonNull ObservableSource<? extends @NonNull T> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T> source2, @NonNull @NonNull BiPredicate<? super @NonNull T,? super @NonNull T> isEqual, int bufferSize)
Returns aSingle
that emits aBoolean
value that indicates whether twoObservableSource
sequences are the same by comparing the items emitted by eachObservableSource
pairwise based on the results of a specified equality function.- Scheduler:
sequenceEqual
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of items emitted by eachObservableSource
- Parameters:
source1
- the firstObservableSource
to comparesource2
- the secondObservableSource
to compareisEqual
- a function used to compare items emitted by eachObservableSource
bufferSize
- the number of items expected from the first and second sourceObservableSource
to be buffered- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orisEqual
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: SequenceEqual
-
sequenceEqual
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Single<java.lang.Boolean> sequenceEqual(@NonNull @NonNull ObservableSource<? extends @NonNull T> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T> source2, int bufferSize)
Returns aSingle
that emits aBoolean
value that indicates whether twoObservableSource
sequences are the same by comparing the items emitted by eachObservableSource
pairwise.- Scheduler:
sequenceEqual
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of items emitted by eachObservableSource
- Parameters:
source1
- the firstObservableSource
to comparesource2
- the secondObservableSource
to comparebufferSize
- the number of items expected from the first and second sourceObservableSource
to be buffered- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifsource1
orsource2
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: SequenceEqual
-
switchOnNext
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> switchOnNext(@NonNull @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources, int bufferSize)
Converts anObservableSource
that emitsObservableSource
s into anObservable
that emits the items emitted by the most recently emitted of thoseObservableSource
s.switchOnNext
subscribes to anObservableSource
that emitsObservableSource
s. Each time it observes one of these emittedObservableSource
s, theObservableSource
returned byswitchOnNext
begins emitting the items emitted by thatObservableSource
. When a new innerObservableSource
is emitted,switchOnNext
stops emitting items from the earlier-emittedObservableSource
and begins emitting items from the new one.The resulting
Observable
completes if both the outerObservableSource
and the last innerObservableSource
, if any, complete. If the outerObservableSource
signals anonError
, the innerObservableSource
is disposed and the error delivered in-sequence.- Scheduler:
switchOnNext
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the item type- Parameters:
sources
- theObservableSource
that emitsObservableSource
sbufferSize
- the expected number of items to cache from the innerObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Switch
-
switchOnNext
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> switchOnNext(@NonNull @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
Converts anObservableSource
that emitsObservableSource
s into anObservable
that emits the items emitted by the most recently emitted of thoseObservableSource
s.switchOnNext
subscribes to anObservableSource
that emitsObservableSource
s. Each time it observes one of these emittedObservableSource
s, theObservableSource
returned byswitchOnNext
begins emitting the items emitted by thatObservableSource
. When a new innerObservableSource
is emitted,switchOnNext
stops emitting items from the earlier-emittedObservableSource
and begins emitting items from the new one.The resulting
Observable
completes if both the outerObservableSource
and the last innerObservableSource
, if any, complete. If the outerObservableSource
signals anonError
, the innerObservableSource
is disposed and the error delivered in-sequence.- Scheduler:
switchOnNext
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the item type- Parameters:
sources
- theObservableSource
that emitsObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Switch
-
switchOnNextDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> switchOnNextDelayError(@NonNull @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
Converts anObservableSource
that emitsObservableSource
s into anObservable
that emits the items emitted by the most recently emitted of thoseObservableSource
s and delays any exception until allObservableSource
s terminate.switchOnNext
subscribes to anObservableSource
that emitsObservableSource
s. Each time it observes one of these emittedObservableSource
s, theObservableSource
returned byswitchOnNext
begins emitting the items emitted by thatObservableSource
. When a new innerObservableSource
is emitted,switchOnNext
stops emitting items from the earlier-emittedObservableSource
and begins emitting items from the new one.The resulting
Observable
completes if both the mainObservableSource
and the last innerObservableSource
, if any, complete. If the mainObservableSource
signals anonError
, the termination of the last innerObservableSource
will emit that error as is or wrapped into aCompositeException
along with the other possible errors the former innerObservableSource
s signaled.- Scheduler:
switchOnNextDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the item type- Parameters:
sources
- theObservableSource
that emitsObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: Switch
-
switchOnNextDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> switchOnNextDelayError(@NonNull @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources, int bufferSize)
Converts anObservableSource
that emitsObservableSource
s into anObservable
that emits the items emitted by the most recently emitted of thoseObservableSource
s and delays any exception until allObservableSource
s terminate.switchOnNext
subscribes to anObservableSource
that emitsObservableSource
s. Each time it observes one of these emittedObservableSource
s, theObservableSource
returned byswitchOnNext
begins emitting the items emitted by thatObservableSource
. When a new innerObservableSource
is emitted,switchOnNext
stops emitting items from the earlier-emittedObservableSource
and begins emitting items from the new one.The resulting
Observable
completes if both the mainObservableSource
and the last innerObservableSource
, if any, complete. If the mainObservableSource
signals anonError
, the termination of the last innerObservableSource
will emit that error as is or wrapped into aCompositeException
along with the other possible errors the former innerObservableSource
s signaled.- Scheduler:
switchOnNextDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the item type- Parameters:
sources
- theObservableSource
that emitsObservableSource
sbufferSize
- the expected number of items to cache from the innerObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: Switch
-
timer
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public static @NonNull Observable<java.lang.Long> timer(long delay, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits0L
after a specified delay, and then completes.- Scheduler:
timer
operates by default on thecomputation
Scheduler
.
- Parameters:
delay
- the initial delay before emitting a single0L
unit
- time units to use fordelay
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Timer
-
timer
@CheckReturnValue @SchedulerSupport("custom") @NonNull public static @NonNull Observable<java.lang.Long> timer(long delay, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits0L
after a specified delay, on a specifiedScheduler
, and then completes.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
delay
- the initial delay before emitting a single 0Lunit
- time units to use fordelay
scheduler
- theScheduler
to use for scheduling the item- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Timer
-
unsafeCreate
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> unsafeCreate(@NonNull @NonNull ObservableSource<@NonNull T> onSubscribe)
Create anObservable
by wrapping anObservableSource
which has to be implemented according to theObservable
specification derived from the Reactive Streams specification by handling disposal correctly; no safeguards are provided by theObservable
itself.- Scheduler:
unsafeCreate
by default doesn't operate on any particularScheduler
.
- Type Parameters:
T
- the value type emitted- Parameters:
onSubscribe
- theObservableSource
instance to wrap- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifonSubscribe
isnull
java.lang.IllegalArgumentException
- if theonSubscribe
is already anObservable
, usewrap(ObservableSource)
in this case- See Also:
wrap(ObservableSource)
-
using
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T,@NonNull D> @NonNull Observable<T> using(@NonNull @NonNull Supplier<? extends @NonNull D> resourceSupplier, @NonNull @NonNull Function<? super @NonNull D,? extends ObservableSource<? extends @NonNull T>> sourceSupplier, @NonNull @NonNull Consumer<? super @NonNull D> resourceCleanup)
Constructs anObservable
that creates a dependent resource object, anObservableSource
with that resource and calls the providedresourceDisposer
function if this inner source terminates or the downstream disposes the flow.- Scheduler:
using
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the element type of the generatedObservable
D
- the type of the resource associated with the output sequence- Parameters:
resourceSupplier
- the factory function to create a resource object that depends on theObservableSource
sourceSupplier
- the factory function to create anObservableSource
resourceCleanup
- the function that will dispose of the resource- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifresourceSupplier
,sourceSupplier
orresourceCleanup
isnull
- See Also:
- ReactiveX operators documentation: Using
-
using
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T,@NonNull D> @NonNull Observable<T> using(@NonNull @NonNull Supplier<? extends @NonNull D> resourceSupplier, @NonNull @NonNull Function<? super @NonNull D,? extends ObservableSource<? extends @NonNull T>> sourceSupplier, @NonNull @NonNull Consumer<? super @NonNull D> resourceCleanup, boolean eager)
Constructs anObservable
that creates a dependent resource object, anObservableSource
with that resource and calls the provideddisposer
function if this inner source terminates or the downstream disposes the flow; doing it before these end-states have been reached ifeager == true
, after otherwise.- Scheduler:
using
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the element type of the generatedObservableSource
D
- the type of the resource associated with the output sequence- Parameters:
resourceSupplier
- the factory function to create a resource object that depends on theObservableSource
sourceSupplier
- the factory function to create anObservableSource
resourceCleanup
- the function that will dispose of the resourceeager
- Iftrue
, the resource disposal will happen either on adispose()
call before the upstream is disposed or just before the emission of a terminal event (onComplete
oronError
). Iffalse
, the resource disposal will happen either on adispose()
call after the upstream is disposed or just after the emission of a terminal event (onComplete
oronError
).- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifresourceSupplier
,sourceSupplier
andresourceCleanup
isnull
- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: Using
-
wrap
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<T> wrap(@NonNull @NonNull ObservableSource<@NonNull T> source)
Wraps anObservableSource
into anObservable
if not already anObservable
.- Scheduler:
wrap
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the value type- Parameters:
source
- theObservableSource
instance to wrap or cast toObservable
- Returns:
- the new
Observable
instance or the same as the source - Throws:
java.lang.NullPointerException
- ifsource
isnull
-
zip
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T,@NonNull R> @NonNull Observable<R> zip(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by anIterable
of otherObservableSource
s.zip
applies this function in strict sequence, so the first item emitted by the resultingObservable
will be the result of the function applied to the first item emitted by each of theObservableSource
s; the second item emitted by the resultingObservable
will be the result of the function applied to the second item emitted by each of thoseObservableSource
s; and so forth.The resulting
Observable<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of theObservableSource
that emits the fewest items.The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:zip(Arrays.asList(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2)), (a) -> a)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.Note on method signature: since Java doesn't allow creating a generic array with
new T[]
, the implementation of this operator has to create anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.- Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common value typeR
- the zipped result type- Parameters:
sources
- anIterable
of sourceObservableSource
szipper
- a function that, when applied to an item emitted by each of theObservableSource
s, results in an item that will be emitted by the resultingObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T,@NonNull R> @NonNull Observable<R> zip(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> zipper, boolean delayError, int bufferSize)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by anIterable
of otherObservableSource
s.zip
applies this function in strict sequence, so the first item emitted by the resultingObservable
will be the result of the function applied to the first item emitted by each of theObservableSource
s; the second item emitted by the resultingObservable
will be the result of the function applied to the second item emitted by each of thoseObservableSource
s; and so forth.The resulting
Observable<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of theObservableSource
that emits the fewest items.The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:zip(Arrays.asList(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2)), (a) -> a)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.Note on method signature: since Java doesn't allow creating a generic array with
new T[]
, the implementation of this operator has to create anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.- Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common source value typeR
- the zipped result type- Parameters:
sources
- anIterable
of sourceObservableSource
szipper
- a function that, when applied to an item emitted by each of theObservableSource
s, results in an item that will be emitted by the resultingObservable
delayError
- delay errors signaled by any of theObservableSource
until allObservableSource
s terminatebufferSize
- the number of elements expected from each sourceObservableSource
to be buffered- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
orzipper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T1,@NonNull T2,@NonNull R> @NonNull Observable<R> zip(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two otherObservableSource
s.zip
applies this function in strict sequence, so the first item emitted by the resultingObservable
will be the result of the function applied to the first item emitted byo1
and the first item emitted byo2
; the second item emitted by the resultingObservable
will be the result of the function applied to the second item emitted byo1
and the second item emitted byo2
; and so forth.The resulting
Observable<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of theObservableSource
that emits the fewest items.The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), (a, b) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.- Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceR
- the zipped result type- Parameters:
source1
- the first sourceObservableSource
source2
- a second sourceObservableSource
zipper
- a function that, when applied to an item emitted by each of theObservableSource
s, results in an item that will be emitted by the resultingObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T1,@NonNull T2,@NonNull R> @NonNull Observable<R> zip(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> zipper, boolean delayError)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two otherObservableSource
s.zip
applies this function in strict sequence, so the first item emitted by the resultingObservable
will be the result of the function applied to the first item emitted byo1
and the first item emitted byo2
; the second item emitted by the resultingObservable
will be the result of the function applied to the second item emitted byo1
and the second item emitted byo2
; and so forth.The resulting
Observable<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of theObservableSource
that emits the fewest items.The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), (a, b) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.- Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceR
- the zipped result type- Parameters:
source1
- the first sourceObservableSource
source2
- a second sourceObservableSource
zipper
- a function that, when applied to an item emitted by each of theObservableSource
s, results in an item that will be emitted by the resultingObservable
delayError
- delay errors from any of theObservableSource
s till the other terminates- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T1,@NonNull T2,@NonNull R> @NonNull Observable<R> zip(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> zipper, boolean delayError, int bufferSize)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two otherObservableSource
s.zip
applies this function in strict sequence, so the first item emitted by the resultingObservable
will be the result of the function applied to the first item emitted byo1
and the first item emitted byo2
; the second item emitted by the resultingObservable
will be the result of the function applied to the second item emitted byo1
and the second item emitted byo2
; and so forth.The resulting
Observable<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of theObservableSource
that emits the fewest items.The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), (a, b) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.- Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceR
- the zipped result type- Parameters:
source1
- the first sourceObservableSource
source2
- a second sourceObservableSource
zipper
- a function that, when applied to an item emitted by each of theObservableSource
s, results in an item that will be emitted by the resultingObservable
delayError
- delay errors from any of theObservableSource
s till the other terminatesbufferSize
- the number of elements expected from each sourceObservableSource
to be buffered- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orzipper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull R> @NonNull Observable<R> zip(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull @NonNull Function3<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of three items emitted, in sequence, by three otherObservableSource
s.zip
applies this function in strict sequence, so the first item emitted by the resultingObservable
will be the result of the function applied to the first item emitted byo1
, the first item emitted byo2
, and the first item emitted byo3
; the second item emitted by the resultingObservable
will be the result of the function applied to the second item emitted byo1
, the second item emitted byo2
, and the second item emitted byo3
; and so forth.The resulting
Observable<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of theObservableSource
that emits the fewest items.The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.- Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceT3
- the value type of the third sourceR
- the zipped result type- Parameters:
source1
- the first sourceObservableSource
source2
- a second sourceObservableSource
source3
- a third sourceObservableSource
zipper
- a function that, when applied to an item emitted by each of theObservableSource
s, results in an item that will be emitted by the resultingObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull R> @NonNull Observable<R> zip(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull @NonNull Function4<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of four items emitted, in sequence, by four otherObservableSource
s.zip
applies this function in strict sequence, so the first item emitted by the resultingObservable
will be the result of the function applied to the first item emitted byo1
, the first item emitted byo2
, the first item emitted byo3
, and the first item emitted by04
; the second item emitted by the resultingObservable
will be the result of the function applied to the second item emitted by each of thoseObservableSource
s; and so forth.The resulting
Observable<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of theObservableSource
that emits the fewest items.The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c, d) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.- Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceT3
- the value type of the third sourceT4
- the value type of the fourth sourceR
- the zipped result type- Parameters:
source1
- the first sourceObservableSource
source2
- a second sourceObservableSource
source3
- a third sourceObservableSource
source4
- a fourth sourceObservableSource
zipper
- a function that, when applied to an item emitted by each of theObservableSource
s, results in an item that will be emitted by the resultingObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull R> @NonNull Observable<R> zip(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull @NonNull Function5<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of five items emitted, in sequence, by five otherObservableSource
s.zip
applies this function in strict sequence, so the first item emitted by the resultingObservable
will be the result of the function applied to the first item emitted byo1
, the first item emitted byo2
, the first item emitted byo3
, the first item emitted byo4
, and the first item emitted byo5
; the second item emitted by the resultingObservable
will be the result of the function applied to the second item emitted by each of thoseObservableSource
s; and so forth.The resulting
Observable<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of theObservableSource
that emits the fewest items.The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c, d, e) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.- Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceT3
- the value type of the third sourceT4
- the value type of the fourth sourceT5
- the value type of the fifth sourceR
- the zipped result type- Parameters:
source1
- the first sourceObservableSource
source2
- a second sourceObservableSource
source3
- a third sourceObservableSource
source4
- a fourth sourceObservableSource
source5
- a fifth sourceObservableSource
zipper
- a function that, when applied to an item emitted by each of theObservableSource
s, results in an item that will be emitted by the resultingObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull R> @NonNull Observable<R> zip(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull @NonNull ObservableSource<? extends @NonNull T6> source6, @NonNull @NonNull Function6<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of six items emitted, in sequence, by six otherObservableSource
s.zip
applies this function in strict sequence, so the first item emitted by the resultingObservable
will be the result of the function applied to the first item emitted by each sourceObservableSource
, the second item emitted by the resultingObservable
will be the result of the function applied to the second item emitted by each of thoseObservableSource
s, and so forth.The resulting
Observable<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of theObservableSource
that emits the fewest items.The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c, d, e, f) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.- Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceT3
- the value type of the third sourceT4
- the value type of the fourth sourceT5
- the value type of the fifth sourceT6
- the value type of the sixth sourceR
- the zipped result type- Parameters:
source1
- the first sourceObservableSource
source2
- a second sourceObservableSource
source3
- a third sourceObservableSource
source4
- a fourth sourceObservableSource
source5
- a fifth sourceObservableSource
source6
- a sixth sourceObservableSource
zipper
- a function that, when applied to an item emitted by each of theObservableSource
s, results in an item that will be emitted by the resultingObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
,source6
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull R> @NonNull Observable<R> zip(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull @NonNull ObservableSource<? extends @NonNull T6> source6, @NonNull @NonNull ObservableSource<? extends @NonNull T7> source7, @NonNull @NonNull Function7<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of seven items emitted, in sequence, by seven otherObservableSource
s.zip
applies this function in strict sequence, so the first item emitted by the resultingObservable
will be the result of the function applied to the first item emitted by each sourceObservableSource
, the second item emitted by the resultingObservable
will be the result of the function applied to the second item emitted by each of thoseObservableSource
s, and so forth.The resulting
Observable<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of theObservableSource
that emits the fewest items.The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c, d, e, f, g) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.- Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceT3
- the value type of the third sourceT4
- the value type of the fourth sourceT5
- the value type of the fifth sourceT6
- the value type of the sixth sourceT7
- the value type of the seventh sourceR
- the zipped result type- Parameters:
source1
- the first sourceObservableSource
source2
- a second sourceObservableSource
source3
- a third sourceObservableSource
source4
- a fourth sourceObservableSource
source5
- a fifth sourceObservableSource
source6
- a sixth sourceObservableSource
source7
- a seventh sourceObservableSource
zipper
- a function that, when applied to an item emitted by each of theObservableSource
s, results in an item that will be emitted by the resultingObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
,source6
,source7
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull R> @NonNull Observable<R> zip(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull @NonNull ObservableSource<? extends @NonNull T6> source6, @NonNull @NonNull ObservableSource<? extends @NonNull T7> source7, @NonNull @NonNull ObservableSource<? extends @NonNull T8> source8, @NonNull @NonNull Function8<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? super @NonNull T8,? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of eight items emitted, in sequence, by eight otherObservableSource
s.zip
applies this function in strict sequence, so the first item emitted by the resultingObservable
will be the result of the function applied to the first item emitted by each sourceObservableSource
, the second item emitted by the resultingObservable
will be the result of the function applied to the second item emitted by each of thoseObservableSource
s, and so forth.The resulting
Observable<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of theObservableSource
that emits the fewest items.The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c, d, e, f, g, h) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.- Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceT3
- the value type of the third sourceT4
- the value type of the fourth sourceT5
- the value type of the fifth sourceT6
- the value type of the sixth sourceT7
- the value type of the seventh sourceT8
- the value type of the eighth sourceR
- the zipped result type- Parameters:
source1
- the first sourceObservableSource
source2
- a second sourceObservableSource
source3
- a third sourceObservableSource
source4
- a fourth sourceObservableSource
source5
- a fifth sourceObservableSource
source6
- a sixth sourceObservableSource
source7
- a seventh sourceObservableSource
source8
- an eighth sourceObservableSource
zipper
- a function that, when applied to an item emitted by each of theObservableSource
s, results in an item that will be emitted by the resultingObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
,source6
,source7
,source8
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull T9,@NonNull R> @NonNull Observable<R> zip(@NonNull @NonNull ObservableSource<? extends @NonNull T1> source1, @NonNull @NonNull ObservableSource<? extends @NonNull T2> source2, @NonNull @NonNull ObservableSource<? extends @NonNull T3> source3, @NonNull @NonNull ObservableSource<? extends @NonNull T4> source4, @NonNull @NonNull ObservableSource<? extends @NonNull T5> source5, @NonNull @NonNull ObservableSource<? extends @NonNull T6> source6, @NonNull @NonNull ObservableSource<? extends @NonNull T7> source7, @NonNull @NonNull ObservableSource<? extends @NonNull T8> source8, @NonNull @NonNull ObservableSource<? extends @NonNull T9> source9, @NonNull @NonNull Function9<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? super @NonNull T7,? super @NonNull T8,? super @NonNull T9,? extends @NonNull R> zipper)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of nine items emitted, in sequence, by nine otherObservableSource
s.zip
applies this function in strict sequence, so the first item emitted by the resultingObservable
will be the result of the function applied to the first item emitted by each sourceObservableSource
, the second item emitted by the resultingObservable
will be the result of the function applied to the second item emitted by each of thoseObservableSource
s, and so forth.The resulting
Observable<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of theObservableSource
that emits the fewest items.The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c, d, e, f, g, h, i) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.- Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceT3
- the value type of the third sourceT4
- the value type of the fourth sourceT5
- the value type of the fifth sourceT6
- the value type of the sixth sourceT7
- the value type of the seventh sourceT8
- the value type of the eighth sourceT9
- the value type of the ninth sourceR
- the zipped result type- Parameters:
source1
- the first sourceObservableSource
source2
- a second sourceObservableSource
source3
- a third sourceObservableSource
source4
- a fourth sourceObservableSource
source5
- a fifth sourceObservableSource
source6
- a sixth sourceObservableSource
source7
- a seventh sourceObservableSource
source8
- an eighth sourceObservableSource
source9
- a ninth sourceObservableSource
zipper
- a function that, when applied to an item emitted by each of theObservableSource
s, results in an item that will be emitted by the resultingObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
,source6
,source7
,source8
,source9
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zipArray
@CheckReturnValue @SchedulerSupport("none") @SafeVarargs @NonNull public static <@NonNull T,@NonNull R> @NonNull Observable<R> zipArray(@NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> zipper, boolean delayError, int bufferSize, @NonNull @NonNull ObservableSource<? extends @NonNull T>... sources)
Returns anObservable
that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by an array of otherObservableSource
s.zip
applies this function in strict sequence, so the first item emitted by the resultingObservable
will be the result of the function applied to the first item emitted by each of theObservableSource
s; the second item emitted by the resultingObservable
will be the result of the function applied to the second item emitted by each of thoseObservableSource
s; and so forth.The resulting
Observable<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of theObservableSource
that emits the fewest items.The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:zip(new ObservableSource[]{range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2)}, (a) -> a)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.Note on method signature: since Java doesn't allow creating a generic array with
new T[]
, the implementation of this operator has to create anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.- Scheduler:
zipArray
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element typeR
- the result type- Parameters:
sources
- an array of sourceObservableSource
szipper
- a function that, when applied to an item emitted by each of theObservableSource
s, results in an item that will be emitted by the resultingObservable
delayError
- delay errors signaled by any of theObservableSource
until allObservableSource
s terminatebufferSize
- the number of elements expected from each sourceObservableSource
to be buffered- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsources
orzipper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Zip
-
all
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<java.lang.Boolean> all(@NonNull @NonNull Predicate<? super @NonNull T> predicate)
Returns aSingle
that emits aBoolean
that indicates whether all of the items emitted by the currentObservable
satisfy a condition.- Scheduler:
all
does not operate by default on a particularScheduler
.
- Parameters:
predicate
- a function that evaluates an item and returns aBoolean
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
- See Also:
- ReactiveX operators documentation: All
-
ambWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> ambWith(@NonNull @NonNull ObservableSource<? extends @NonNull T> other)
Mirrors the currentObservable
or the otherObservableSource
provided of which the first either emits an item or sends a termination notification.When the current
Observable
signals an item or terminates first, the subscription to the otherObservableSource
is disposed. If the otherObservableSource
signals an item or terminates first, the subscription to the currentObservable
is disposed.- Scheduler:
ambWith
does not operate by default on a particularScheduler
.- Error handling:
-
If the losing
ObservableSource
signals an error, the error is routed to the global error handler viaRxJavaPlugins.onError(Throwable)
.
- Parameters:
other
- anObservableSource
competing to react first. A subscription to this provided source will occur after subscribing to the current source.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- See Also:
- ReactiveX operators documentation: Amb
-
any
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<java.lang.Boolean> any(@NonNull @NonNull Predicate<? super @NonNull T> predicate)
Returns aSingle
that emitstrue
if any item emitted by the currentObservable
satisfies a specified condition, otherwisefalse
. Note: this always emitsfalse
if the currentObservable
is empty.In Rx.Net this is the
any
Observer
but we renamed it in RxJava to better match Java naming idioms.- Scheduler:
any
does not operate by default on a particularScheduler
.
- Parameters:
predicate
- the condition to test items emitted by the currentObservable
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
- See Also:
- ReactiveX operators documentation: Contains
-
blockingFirst
@CheckReturnValue @SchedulerSupport("none") @NonNull public final T blockingFirst()
Returns the first item emitted by the currentObservable
, or throwsNoSuchElementException
if it emits no items.- Scheduler:
blockingFirst
does not operate by default on a particularScheduler
.- Error handling:
- If the source signals an error, the operator wraps a checked
Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.
- Returns:
- the first item emitted by the current
Observable
- Throws:
java.util.NoSuchElementException
- if the currentObservable
emits no items- See Also:
- ReactiveX documentation: First
-
blockingFirst
@CheckReturnValue @SchedulerSupport("none") @NonNull public final T blockingFirst(@NonNull @NonNull T defaultItem)
Returns the first item emitted by the currentObservable
, or a default value if it emits no items.- Scheduler:
blockingFirst
does not operate by default on a particularScheduler
.- Error handling:
- If the source signals an error, the operator wraps a checked
Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.
- Parameters:
defaultItem
- a default value to return if the currentObservable
emits no items- Returns:
- the first item emitted by the current
Observable
, or the default value if it emits no items - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
- See Also:
- ReactiveX documentation: First
-
blockingForEach
@SchedulerSupport("none") public final void blockingForEach(@NonNull @NonNull Consumer<? super @NonNull T> onNext)
Consumes the currentObservable
in a blocking fashion and invokes the givenConsumer
with each upstream item on the current thread until the upstream terminates.Note: the method will only return if the upstream terminates or the current thread is interrupted.
This method executes the
Consumer
on the current thread whilesubscribe(Consumer)
executes the consumer on the original caller thread of the sequence.- Scheduler:
blockingForEach
does not operate by default on a particularScheduler
.- Error handling:
- If the source signals an error, the operator wraps a checked
Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.
- Parameters:
onNext
- theConsumer
to invoke for each item emitted by theObservable
- Throws:
java.lang.NullPointerException
- ifonNext
isnull
java.lang.RuntimeException
- if an error occurs- See Also:
- ReactiveX documentation: Subscribe,
subscribe(Consumer)
,blockingForEach(Consumer, int)
-
blockingForEach
@SchedulerSupport("none") public final void blockingForEach(@NonNull @NonNull Consumer<? super @NonNull T> onNext, int capacityHint)
Consumes the currentObservable
in a blocking fashion and invokes the givenConsumer
with each upstream item on the current thread until the upstream terminates.Note: the method will only return if the upstream terminates or the current thread is interrupted.
This method executes the
Consumer
on the current thread whilesubscribe(Consumer)
executes the consumer on the original caller thread of the sequence.- Scheduler:
blockingForEach
does not operate by default on a particularScheduler
.- Error handling:
- If the source signals an error, the operator wraps a checked
Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.
- Parameters:
onNext
- theConsumer
to invoke for each item emitted by theObservable
capacityHint
- the number of items expected to be buffered (allows reducing buffer reallocations)- Throws:
java.lang.NullPointerException
- ifonNext
isnull
java.lang.IllegalArgumentException
- ifcapacityHint
is non-positivejava.lang.RuntimeException
- if an error occurs;Error
s andRuntimeException
s are rethrown as they are, checkedException
s are wrapped intoRuntimeException
s- See Also:
- ReactiveX documentation: Subscribe,
subscribe(Consumer)
-
blockingIterable
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull java.lang.Iterable<T> blockingIterable()
Exposes the currentObservable
as anIterable
which, when iterated, subscribes to the currentObservable
and blocks until the currentObservable
emits items or terminates.- Scheduler:
blockingIterable
does not operate by default on a particularScheduler
.
- Returns:
- the new
Iterable
instance - See Also:
- ReactiveX documentation: To
-
blockingIterable
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull java.lang.Iterable<T> blockingIterable(int capacityHint)
Exposes the currentObservable
as anIterable
which, when iterated, subscribes to the currentObservable
and blocks until the currentObservable
emits items or terminates.- Scheduler:
blockingIterable
does not operate by default on a particularScheduler
.
- Parameters:
capacityHint
- the expected number of items to be buffered- Returns:
- the new
Iterable
instance - Throws:
java.lang.IllegalArgumentException
- ifcapacityHint
is non-positive- See Also:
- ReactiveX documentation: To
-
blockingLast
@CheckReturnValue @SchedulerSupport("none") @NonNull public final T blockingLast()
Returns the last item emitted by the currentObservable
, or throwsNoSuchElementException
if the currentObservable
emits no items.- Scheduler:
blockingLast
does not operate by default on a particularScheduler
.- Error handling:
- If the source signals an error, the operator wraps a checked
Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.
- Returns:
- the last item emitted by the current
Observable
- Throws:
java.util.NoSuchElementException
- if the currentObservable
emits no items- See Also:
- ReactiveX documentation: Last
-
blockingLast
@CheckReturnValue @SchedulerSupport("none") @NonNull public final T blockingLast(@NonNull @NonNull T defaultItem)
Returns the last item emitted by the currentObservable
, or a default value if it emits no items.- Scheduler:
blockingLast
does not operate by default on a particularScheduler
.- Error handling:
- If the source signals an error, the operator wraps a checked
Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.
- Parameters:
defaultItem
- a default value to return if the currentObservable
emits no items- Returns:
- the last item emitted by the
Observable
, or the default value if it emits no items - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
- See Also:
- ReactiveX documentation: Last
-
blockingLatest
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull java.lang.Iterable<T> blockingLatest()
Returns anIterable
that returns the latest item emitted by the currentObservable
, waiting if necessary for one to become available.If the current
Observable
produces items faster thanIterator.next
takes them,onNext
events might be skipped, butonError
oronComplete
events are not.Note also that an
onNext
directly followed byonComplete
might hide theonNext
event.- Scheduler:
blockingLatest
does not operate by default on a particularScheduler
.
- Returns:
- the new
Iterable
instance - See Also:
- ReactiveX documentation: First
-
blockingMostRecent
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull java.lang.Iterable<T> blockingMostRecent(@NonNull @NonNull T initialItem)
Returns anIterable
that always returns the item most recently emitted by the currentObservable
.- Scheduler:
blockingMostRecent
does not operate by default on a particularScheduler
.
- Parameters:
initialItem
- the initial value that theIterable
sequence will yield if the currentObservable
has not yet emitted an item- Returns:
- the new
Iterable
instance - Throws:
java.lang.NullPointerException
- ifinitialItem
isnull
- See Also:
- ReactiveX documentation: First
-
blockingNext
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull java.lang.Iterable<T> blockingNext()
Returns anIterable
that blocks until the currentObservable
emits another item, then returns that item.- Scheduler:
blockingNext
does not operate by default on a particularScheduler
.
- Returns:
- the new
Iterable
instance - See Also:
- ReactiveX documentation: TakeLast
-
blockingSingle
@CheckReturnValue @SchedulerSupport("none") @NonNull public final T blockingSingle()
If the currentObservable
completes after emitting a single item, return that item, otherwise throw aNoSuchElementException
.- Scheduler:
blockingSingle
does not operate by default on a particularScheduler
.- Error handling:
- If the source signals an error, the operator wraps a checked
Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.
- Returns:
- the single item emitted by the current
Observable
- See Also:
- ReactiveX documentation: First
-
blockingSingle
@CheckReturnValue @SchedulerSupport("none") @NonNull public final T blockingSingle(@NonNull @NonNull T defaultItem)
If the currentObservable
completes after emitting a single item, return that item; if it emits more than one item, throw anIllegalArgumentException
; if it emits no items, return a default value.- Scheduler:
blockingSingle
does not operate by default on a particularScheduler
.- Error handling:
- If the source signals an error, the operator wraps a checked
Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.
- Parameters:
defaultItem
- a default value to return if the currentObservable
emits no items- Returns:
- the single item emitted by the current
Observable
, or the default value if it emits no items - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
- See Also:
- ReactiveX documentation: First
-
toFuture
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull java.util.concurrent.Future<T> toFuture()
Returns aFuture
representing the only value emitted by the currentObservable
.If the
Observable
emits more than one item,Future
will receive anIndexOutOfBoundsException
. If theObservable
is empty,Future
will receive anNoSuchElementException
. TheObservable
source has to terminate in order for the returnedFuture
to terminate as well.If the
Observable
may emit more than one item, useObservable.toList().toFuture()
.- Scheduler:
toFuture
does not operate by default on a particularScheduler
.
- Returns:
- the new
Future
instance - See Also:
- ReactiveX documentation: To,
singleOrErrorStage()
-
blockingSubscribe
@SchedulerSupport("none") public final void blockingSubscribe()
Runs the currentObservable
to a terminal event, ignoring any values and rethrowing any exception.Note that calling this method will block the caller thread until the upstream terminates normally or with an error. Therefore, calling this method from special threads such as the Android Main Thread or the Swing Event Dispatch Thread is not recommended.
- Scheduler:
blockingSubscribe
does not operate by default on a particularScheduler
.
-
blockingSubscribe
@SchedulerSupport("none") public final void blockingSubscribe(@NonNull @NonNull Consumer<? super @NonNull T> onNext)
Subscribes to the source and calls the given callbacks on the current thread.If the
Observable
emits an error, it is wrapped into anOnErrorNotImplementedException
and routed to theRxJavaPlugins.onError(Throwable)
handler. Using the overloadsblockingSubscribe(Consumer, Consumer)
orblockingSubscribe(Consumer, Consumer, Action)
instead is recommended.Note that calling this method will block the caller thread until the upstream terminates normally or with an error. Therefore, calling this method from special threads such as the Android Main Thread or the Swing Event Dispatch Thread is not recommended.
- Scheduler:
blockingSubscribe
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- the callback action for each source value- Throws:
java.lang.NullPointerException
- ifonNext
isnull
- Since:
- 2.0
- See Also:
blockingSubscribe(Consumer, Consumer)
,blockingSubscribe(Consumer, Consumer, Action)
-
blockingSubscribe
@SchedulerSupport("none") public final void blockingSubscribe(@NonNull @NonNull Consumer<? super @NonNull T> onNext, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError)
Subscribes to the source and calls the given callbacks on the current thread.Note that calling this method will block the caller thread until the upstream terminates normally or with an error. Therefore, calling this method from special threads such as the Android Main Thread or the Swing Event Dispatch Thread is not recommended.
- Scheduler:
blockingSubscribe
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- the callback action for each source valueonError
- the callback action for an error event- Throws:
java.lang.NullPointerException
- ifonNext
oronError
isnull
- Since:
- 2.0
- See Also:
blockingSubscribe(Consumer, Consumer, Action)
-
blockingSubscribe
@SchedulerSupport("none") public final void blockingSubscribe(@NonNull @NonNull Consumer<? super @NonNull T> onNext, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull @NonNull Action onComplete)
Subscribes to the source and calls the given callbacks on the current thread.Note that calling this method will block the caller thread until the upstream terminates normally or with an error. Therefore, calling this method from special threads such as the Android Main Thread or the Swing Event Dispatch Thread is not recommended.
- Scheduler:
blockingSubscribe
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- the callback action for each source valueonError
- the callback action for an error eventonComplete
- the callback action for the completion event.- Throws:
java.lang.NullPointerException
- ifonNext
,onError
oronComplete
isnull
- Since:
- 2.0
-
blockingSubscribe
@SchedulerSupport("none") public final void blockingSubscribe(@NonNull @NonNull Observer<? super @NonNull T> observer)
Subscribes to the source and calls theObserver
methods on the current thread.Note that calling this method will block the caller thread until the upstream terminates normally, with an error or the
Observer
disposes theDisposable
it receives viaObserver.onSubscribe(Disposable)
. Therefore, calling this method from special threads such as the Android Main Thread or the Swing Event Dispatch Thread is not recommended.- Scheduler:
blockingSubscribe
does not operate by default on a particularScheduler
.
- Parameters:
observer
- theObserver
instance to forward events and calls to in the current thread- Throws:
java.lang.NullPointerException
- ifobserver
isnull
- Since:
- 2.0
-
buffer
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<@NonNull java.util.List<T>> buffer(int count)
Returns anObservable
that emits buffers of items it collects from the currentObservable
. The resultingObservable
emits connected, non-overlapping buffers, each containingcount
items. When the currentObservable
completes, the resultingObservable
emits the current buffer and propagates the notification from the currentObservable
. Note that if the currentObservable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Parameters:
count
- the maximum number of items in each buffer before it should be emitted- Returns:
- the new
Observable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<@NonNull java.util.List<T>> buffer(int count, int skip)
Returns anObservable
that emits buffers of items it collects from the currentObservable
. The resultingObservable
emits buffers everyskip
items, each containingcount
items. When the currentObservable
completes, the resultingObservable
emits the current buffer and propagates the notification from the currentObservable
. Note that if the currentObservable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Parameters:
count
- the maximum size of each buffer before it should be emittedskip
- how many items emitted by the currentObservable
should be skipped before starting a new buffer. Note that whenskip
andcount
are equal, this is the same operation asbuffer(int)
.- Returns:
- the new
Observable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
orskip
is non-positive- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Observable<U> buffer(int count, int skip, @NonNull @NonNull Supplier<@NonNull U> bufferSupplier)
Returns anObservable
that emits buffers of items it collects from the currentObservable
. The resultingObservable
emits buffers everyskip
items, each containingcount
items. When the currentObservable
completes, the resultingObservable
emits the current buffer and propagates the notification from the currentObservable
. Note that if the currentObservable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the collection subclass type to buffer into- Parameters:
count
- the maximum size of each buffer before it should be emittedskip
- how many items emitted by the currentObservable
should be skipped before starting a new buffer. Note that whenskip
andcount
are equal, this is the same operation asbuffer(int)
.bufferSupplier
- a factory function that returns an instance of the collection subclass to be used and returned as the buffer- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifbufferSupplier
isnull
java.lang.IllegalArgumentException
- ifcount
orskip
is non-positive- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Observable<U> buffer(int count, @NonNull @NonNull Supplier<@NonNull U> bufferSupplier)
Returns anObservable
that emits buffers of items it collects from the currentObservable
. The resultingObservable
emits connected, non-overlapping buffers, each containingcount
items. When the currentObservable
completes, the resultingObservable
emits the current buffer and propagates the notification from the currentObservable
. Note that if the currentObservable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the collection subclass type to buffer into- Parameters:
count
- the maximum number of items in each buffer before it should be emittedbufferSupplier
- a factory function that returns an instance of the collection subclass to be used and returned as the buffer- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifbufferSupplier
isnull
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<@NonNull java.util.List<T>> buffer(long timespan, long timeskip, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits buffers of items it collects from the currentObservable
. The resultingObservable
starts a new buffer periodically, as determined by thetimeskip
argument. It emits each buffer after a fixed timespan, specified by thetimespan
argument. When the currentObservable
completes, the resultingObservable
emits the current buffer and propagates the notification from the currentObservable
. Note that if the currentObservable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Scheduler:
- This version of
buffer
operates by default on thecomputation
Scheduler
.
- Parameters:
timespan
- the period of time each buffer collects items before it is emittedtimeskip
- the period of time after which a new buffer will be createdunit
- the unit of time that applies to thetimespan
andtimeskip
arguments- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<@NonNull java.util.List<T>> buffer(long timespan, long timeskip, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits buffers of items it collects from the currentObservable
. The resultingObservable
starts a new buffer periodically, as determined by thetimeskip
argument, and on the specifiedscheduler
. It emits each buffer after a fixed timespan, specified by thetimespan
argument. When the currentObservable
completes, the resultingObservable
emits the current buffer and propagates the notification from the currentObservable
. Note that if the currentObservable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timespan
- the period of time each buffer collects items before it is emittedtimeskip
- the period of time after which a new buffer will be createdunit
- the unit of time that applies to thetimespan
andtimeskip
argumentsscheduler
- theScheduler
to use when determining the end and start of a buffer- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final <@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Observable<U> buffer(long timespan, long timeskip, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, @NonNull @NonNull Supplier<@NonNull U> bufferSupplier)
Returns anObservable
that emits buffers of items it collects from the currentObservable
. The resultingObservable
starts a new buffer periodically, as determined by thetimeskip
argument, and on the specifiedscheduler
. It emits each buffer after a fixed timespan, specified by thetimespan
argument. When the currentObservable
completes, the resultingObservable
emits the current buffer and propagates the notification from the currentObservable
. Note that if the currentObservable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Type Parameters:
U
- the collection subclass type to buffer into- Parameters:
timespan
- the period of time each buffer collects items before it is emittedtimeskip
- the period of time after which a new buffer will be createdunit
- the unit of time that applies to thetimespan
andtimeskip
argumentsscheduler
- theScheduler
to use when determining the end and start of a bufferbufferSupplier
- a factory function that returns an instance of the collection subclass to be used and returned as the buffer- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
,scheduler
orbufferSupplier
isnull
- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<@NonNull java.util.List<T>> buffer(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits buffers of items it collects from the currentObservable
. The resultingObservable
emits connected, non-overlapping buffers, each of a fixed duration specified by thetimespan
argument. When the currentObservable
completes, the resultingObservable
emits the current buffer and propagates the notification from the currentObservable
. Note that if the currentObservable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Scheduler:
- This version of
buffer
operates by default on thecomputation
Scheduler
.
- Parameters:
timespan
- the period of time each buffer collects items before it is emitted and replaced with a new bufferunit
- the unit of time that applies to thetimespan
argument- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<@NonNull java.util.List<T>> buffer(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, int count)
Returns anObservable
that emits buffers of items it collects from the currentObservable
. The resultingObservable
emits connected, non-overlapping buffers, each of a fixed duration specified by thetimespan
argument or a maximum size specified by thecount
argument (whichever is reached first). When the currentObservable
completes, the resultingObservable
emits the current buffer and propagates the notification from the currentObservable
. Note that if the currentObservable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Scheduler:
- This version of
buffer
operates by default on thecomputation
Scheduler
.
- Parameters:
timespan
- the period of time each buffer collects items before it is emitted and replaced with a new bufferunit
- the unit of time which applies to thetimespan
argumentcount
- the maximum size of each buffer before it is emitted- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<@NonNull java.util.List<T>> buffer(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, int count)
Returns anObservable
that emits buffers of items it collects from the currentObservable
. The resultingObservable
emits connected, non-overlapping buffers, each of a fixed duration specified by thetimespan
argument as measured on the specifiedscheduler
, or a maximum size specified by thecount
argument (whichever is reached first). When the currentObservable
completes, the resultingObservable
emits the current buffer and propagates the notification from the currentObservable
. Note that if the currentObservable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timespan
- the period of time each buffer collects items before it is emitted and replaced with a new bufferunit
- the unit of time which applies to thetimespan
argumentscheduler
- theScheduler
to use when determining the end and start of a buffercount
- the maximum size of each buffer before it is emitted- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final <@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Observable<U> buffer(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, int count, @NonNull @NonNull Supplier<@NonNull U> bufferSupplier, boolean restartTimerOnMaxSize)
Returns anObservable
that emits buffers of items it collects from the currentObservable
. The resultingObservable
emits connected, non-overlapping buffers, each of a fixed duration specified by thetimespan
argument as measured on the specifiedscheduler
, or a maximum size specified by thecount
argument (whichever is reached first). When the currentObservable
completes, the resultingObservable
emits the current buffer and propagates the notification from the currentObservable
. Note that if the currentObservable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Type Parameters:
U
- the collection subclass type to buffer into- Parameters:
timespan
- the period of time each buffer collects items before it is emitted and replaced with a new bufferunit
- the unit of time which applies to thetimespan
argumentscheduler
- theScheduler
to use when determining the end and start of a buffercount
- the maximum size of each buffer before it is emittedbufferSupplier
- a factory function that returns an instance of the collection subclass to be used and returned as the bufferrestartTimerOnMaxSize
- iftrue
, the time window is restarted when the max capacity of the current buffer is reached- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
,scheduler
orbufferSupplier
isnull
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<@NonNull java.util.List<T>> buffer(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits buffers of items it collects from the currentObservable
. The resultingObservable
emits connected, non-overlapping buffers, each of a fixed duration specified by thetimespan
argument and on the specifiedscheduler
. When the currentObservable
completes, the resultingObservable
emits the current buffer and propagates the notification from the currentObservable
. Note that if the currentObservable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timespan
- the period of time each buffer collects items before it is emitted and replaced with a new bufferunit
- the unit of time which applies to thetimespan
argumentscheduler
- theScheduler
to use when determining the end and start of a buffer- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull TOpening,@NonNull TClosing> @NonNull Observable<@NonNull java.util.List<T>> buffer(@NonNull @NonNull ObservableSource<? extends @NonNull TOpening> openingIndicator, @NonNull @NonNull Function<? super @NonNull TOpening,? extends ObservableSource<? extends @NonNull TClosing>> closingIndicator)
Returns anObservable
that emits buffers of items it collects from the currentObservable
. The resultingObservable
emits buffers that it creates when the specifiedopeningIndicator
ObservableSource
emits an item, and closes when theObservableSource
returned fromclosingIndicator
emits an item. If any of the currentObservable
,openingIndicator
orclosingIndicator
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Type Parameters:
TOpening
- the element type of the buffer-openingObservableSource
TClosing
- the element type of the individual buffer-closingObservableSource
s- Parameters:
openingIndicator
- theObservableSource
that, when it emits an item, causes a new buffer to be createdclosingIndicator
- theFunction
that is used to produce anObservableSource
for every buffer created. When this indicatorObservableSource
emits an item, the associated buffer is emitted.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifopeningIndicator
orclosingIndicator
isnull
- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull TOpening,@NonNull TClosing,@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Observable<U> buffer(@NonNull @NonNull ObservableSource<? extends @NonNull TOpening> openingIndicator, @NonNull @NonNull Function<? super @NonNull TOpening,? extends ObservableSource<? extends @NonNull TClosing>> closingIndicator, @NonNull @NonNull Supplier<@NonNull U> bufferSupplier)
Returns anObservable
that emits buffers of items it collects from the currentObservable
. The resultingObservable
emits buffers that it creates when the specifiedopeningIndicator
ObservableSource
emits an item, and closes when theObservableSource
returned fromclosingIndicator
emits an item. If any of the currentObservable
,openingIndicator
orclosingIndicator
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the collection subclass type to buffer intoTOpening
- the element type of the buffer-openingObservableSource
TClosing
- the element type of the individual buffer-closingObservableSource
s- Parameters:
openingIndicator
- theObservableSource
that, when it emits an item, causes a new buffer to be createdclosingIndicator
- theFunction
that is used to produce anObservableSource
for every buffer created. When this indicatorObservableSource
emits an item, the associated buffer is emitted.bufferSupplier
- a factory function that returns an instance of the collection subclass to be used and returned as the buffer- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifopeningIndicator
,closingIndicator
orbufferSupplier
isnull
- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull B> @NonNull Observable<@NonNull java.util.List<T>> buffer(@NonNull @NonNull ObservableSource<@NonNull B> boundaryIndicator)
Returns anObservable
that emits non-overlapping buffered items from the currentObservable
each time the specified boundaryObservableSource
emits an item.Completion of either the source or the boundary
ObservableSource
causes the returnedObservableSource
to emit the latest buffer and complete. If either the currentObservable
or the boundaryObservableSource
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Type Parameters:
B
- the boundary value type (ignored)- Parameters:
boundaryIndicator
- the boundaryObservableSource
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifboundaryIndicator
isnull
- See Also:
buffer(ObservableSource, int)
, ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull B> @NonNull Observable<@NonNull java.util.List<T>> buffer(@NonNull @NonNull ObservableSource<@NonNull B> boundaryIndicator, int initialCapacity)
Returns anObservable
that emits non-overlapping buffered items from the currentObservable
each time the specified boundaryObservableSource
emits an item.Completion of either the source or the boundary
ObservableSource
causes the returnedObservableSource
to emit the latest buffer and complete. If either the currentObservable
or the boundaryObservableSource
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Type Parameters:
B
- the boundary value type (ignored)- Parameters:
boundaryIndicator
- the boundaryObservableSource
initialCapacity
- the initial capacity of each buffer chunk- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifboundaryIndicator
isnull
java.lang.IllegalArgumentException
- ifinitialCapacity
is non-positive- See Also:
- ReactiveX operators documentation: Buffer,
buffer(ObservableSource)
-
buffer
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull B,@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Observable<U> buffer(@NonNull @NonNull ObservableSource<@NonNull B> boundaryIndicator, @NonNull @NonNull Supplier<@NonNull U> bufferSupplier)
Returns anObservable
that emits non-overlapping buffered items from the currentObservable
each time the specified boundaryObservableSource
emits an item.Completion of either the source or the boundary
ObservableSource
causes the returnedObservableSource
to emit the latest buffer and complete. If either the currentObservable
or the boundaryObservableSource
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the collection subclass type to buffer intoB
- the boundary value type (ignored)- Parameters:
boundaryIndicator
- the boundaryObservableSource
bufferSupplier
- a factory function that returns an instance of the collection subclass to be used and returned as the buffer- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifboundaryIndicator
orbufferSupplier
isnull
- See Also:
buffer(ObservableSource, int)
, ReactiveX operators documentation: Buffer
-
cache
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> cache()
Returns anObservable
that subscribes to the currentObservable
lazily, caches all of its events and replays them, in the same order as received, to all the downstream observers.This is useful when you want an
Observable
to cache responses and you can't control the subscribe/dispose behavior of all theObserver
s.The operator subscribes only when the first downstream observer subscribes and maintains a single subscription towards the current
Observable
. In contrast, the operator family ofreplay()
that return aConnectableObservable
require an explicit call toConnectableObservable.connect()
.Note: You sacrifice the ability to dispose the origin when you use the
cache
operator so be careful not to use this operator onObservable
s that emit an infinite or very large number of items that will use up memory. A possible workaround is to applytakeUntil
with a predicate or another source before (and perhaps after) the application ofcache()
.
Since the operator doesn't allow clearing the cached values either, the possible workaround is to forget all references to it viaAtomicBoolean shouldStop = new AtomicBoolean(); source.takeUntil(v -> shouldStop.get()) .cache() .takeUntil(v -> shouldStop.get()) .subscribe(...);
onTerminateDetach()
applied along with the previous workaround:AtomicBoolean shouldStop = new AtomicBoolean(); source.takeUntil(v -> shouldStop.get()) .onTerminateDetach() .cache() .takeUntil(v -> shouldStop.get()) .onTerminateDetach() .subscribe(...);
- Scheduler:
cache
does not operate by default on a particularScheduler
.
- Returns:
- the new
Observable
instance - See Also:
- ReactiveX operators documentation: Replay,
takeUntil(Predicate)
,takeUntil(ObservableSource)
-
cacheWithInitialCapacity
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> cacheWithInitialCapacity(int initialCapacity)
Returns anObservable
that subscribes to the currentObservable
lazily, caches all of its events and replays them, in the same order as received, to all the downstream observers.This is useful when you want an
Observable
to cache responses and you can't control the subscribe/dispose behavior of all theObserver
s.The operator subscribes only when the first downstream observer subscribes and maintains a single subscription towards the current
Observable
. In contrast, the operator family ofreplay()
that return aConnectableObservable
require an explicit call toConnectableObservable.connect()
.Note: You sacrifice the ability to dispose the origin when you use the
cache
operator so be careful not to use this operator onObservable
s that emit an infinite or very large number of items that will use up memory. A possible workaround is to apply `takeUntil` with a predicate or another source before (and perhaps after) the application ofcache()
.
Since the operator doesn't allow clearing the cached values either, the possible workaround is to forget all references to it viaAtomicBoolean shouldStop = new AtomicBoolean(); source.takeUntil(v -> shouldStop.get()) .cache() .takeUntil(v -> shouldStop.get()) .subscribe(...);
onTerminateDetach()
applied along with the previous workaround:AtomicBoolean shouldStop = new AtomicBoolean(); source.takeUntil(v -> shouldStop.get()) .onTerminateDetach() .cache() .takeUntil(v -> shouldStop.get()) .onTerminateDetach() .subscribe(...);
- Scheduler:
cacheWithInitialCapacity
does not operate by default on a particularScheduler
.
Note: The capacity hint is not an upper bound on cache size. For that, consider
replay(int)
in combination withConnectableObservable.autoConnect()
or similar.- Parameters:
initialCapacity
- hint for number of items to cache (for optimizing underlying data structure)- Returns:
- the new
Observable
instance - Throws:
java.lang.IllegalArgumentException
- ifinitialCapacity
is non-positive- See Also:
- ReactiveX operators documentation: Replay,
takeUntil(Predicate)
,takeUntil(ObservableSource)
-
cast
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U> @NonNull Observable<U> cast(@NonNull @NonNull java.lang.Class<@NonNull U> clazz)
Returns anObservable
that emits the upstream items while they can be cast viaClass.cast(Object)
until the upstream terminates, or until the upstream signals an item which can't be cast, resulting in aClassCastException
to be signaled to the downstream.- Scheduler:
cast
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the output value type cast to- Parameters:
clazz
- the target class to use to try and cast the upstream items into- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifclazz
isnull
- See Also:
- ReactiveX operators documentation: Map
-
collect
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U> @NonNull Single<U> collect(@NonNull @NonNull Supplier<? extends @NonNull U> initialItemSupplier, @NonNull @NonNull BiConsumer<? super @NonNull U,? super @NonNull T> collector)
Collects items emitted by the finite sourceObservable
into a single mutable data structure and returns aSingle
that emits this structure.This is a simplified version of
reduce
that does not need to return the state on each pass.Note that this operator requires the upstream to signal
onComplete
for the accumulator object to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
collect
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the accumulator and output type- Parameters:
initialItemSupplier
- the mutable data structure that will collect the itemscollector
- a function that accepts thestate
and an emitted item, and modifies the accumulator accordingly accordingly- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifinitialItemSupplier
orcollector
isnull
- See Also:
- ReactiveX operators documentation: Reduce
-
collectInto
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U> @NonNull Single<U> collectInto(@NonNull @NonNull U initialItem, @NonNull @NonNull BiConsumer<? super @NonNull U,? super @NonNull T> collector)
Collects items emitted by the finite sourceObservable
into a single mutable data structure and returns aSingle
that emits this structure.This is a simplified version of
reduce
that does not need to return the state on each pass.Note that this operator requires the upstream to signal
onComplete
for the accumulator object to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
collectInto
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the accumulator and output type- Parameters:
initialItem
- the mutable data structure that will collect the itemscollector
- a function that accepts thestate
and an emitted item, and modifies the accumulator accordingly accordingly- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifinitialItem
orcollector
isnull
- See Also:
- ReactiveX operators documentation: Reduce
-
compose
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> compose(@NonNull @NonNull ObservableTransformer<? super @NonNull T,? extends @NonNull R> composer)
Transform the currentObservable
by applying a particularObservableTransformer
function to it.This method operates on the
Observable
itself whereaslift(io.reactivex.rxjava3.core.ObservableOperator<? extends R, ? super T>)
operates on theObservableSource
'sObserver
s.If the operator you are creating is designed to act on the individual items emitted by the current
Observable
, uselift(io.reactivex.rxjava3.core.ObservableOperator<? extends R, ? super T>)
. If your operator is designed to transform the currentObservable
as a whole (for instance, by applying a particular set of existing RxJava operators to it) usecompose
.- Scheduler:
compose
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the value type of the outputObservableSource
- Parameters:
composer
- implements the function that transforms the currentObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifcomposer
isnull
- See Also:
- RxJava wiki: Implementing Your Own Operators
-
concatMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMap(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper)
Returns a newObservable
that emits items resulting from applying a function that you supply to each item emitted by the currentObservable
, where that function returns anObservableSource
, and then emitting the items that result from concatenating those returnedObservableSource
s.Note that there is no guarantee where the given
mapper
function will be executed; it could be on the subscribing thread, on the upstream thread signaling the new item to be mapped or on the thread where the inner source terminates. To ensure themapper
function is confined to a known thread, use theconcatMap(Function, int, Scheduler)
overload.- Scheduler:
concatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the type of the innerObservableSource
sources and thus the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the currentObservable
, returns anObservableSource
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- See Also:
- ReactiveX operators documentation: FlatMap,
concatMap(Function, int, Scheduler)
-
concatMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMap(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, int bufferSize)
Returns a newObservable
that emits items resulting from applying a function that you supply to each item emitted by the currentObservable
, where that function returns anObservableSource
, and then emitting the items that result from concatenating those returnedObservableSource
s.Note that there is no guarantee where the given
mapper
function will be executed; it could be on the subscribing thread, on the upstream thread signaling the new item to be mapped or on the thread where the inner source terminates. To ensure themapper
function is confined to a known thread, use theconcatMap(Function, int, Scheduler)
overload.- Scheduler:
concatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the type of the innerObservableSource
sources and thus the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the currentObservable
, returns anObservableSource
bufferSize
- the number of elements expected from the currentObservable
to be buffered- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: FlatMap,
concatMap(Function, int, Scheduler)
-
concatMap
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMap(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, int bufferSize, @NonNull @NonNull Scheduler scheduler)
Returns a newObservable
that emits items resulting from applying a function that you supply to each item emitted by the currentObservable
, where that function returns anObservableSource
, and then emitting the items that result from concatenating those returnedObservableSource
s.The difference between
concatMap(Function, int)
and this operator is that this operator guarantees themapper
function is executed on the specified scheduler.- Scheduler:
concatMap
executes the givenmapper
function on the providedScheduler
.
- Type Parameters:
R
- the type of the innerObservableSource
sources and thus the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the currentObservable
, returns anObservableSource
bufferSize
- the number of elements expected from the currentObservable
to be bufferedscheduler
- the scheduler where themapper
function will be executed- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
orscheduler
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 3.0.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
concatMapDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper)
Maps each of the items into anObservableSource
, subscribes to them one after the other, one at a time and emits their values in order while delaying any error from either this or any of the innerObservableSource
s till all of them terminate.Note that there is no guarantee where the given
mapper
function will be executed; it could be on the subscribing thread, on the upstream thread signaling the new item to be mapped or on the thread where the inner source terminates. To ensure themapper
function is confined to a known thread, use theconcatMapDelayError(Function, boolean, int, Scheduler)
overload.- Scheduler:
concatMapDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the result value type- Parameters:
mapper
- the function that maps the items of the currentObservable
into the innerObservableSource
s.- Returns:
- the new
Observable
instance with the concatenation behavior - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- See Also:
concatMapDelayError(Function, boolean, int, Scheduler)
-
concatMapDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, boolean tillTheEnd, int bufferSize)
Maps each of the items into anObservableSource
, subscribes to them one after the other, one at a time and emits their values in order while delaying any error from either this or any of the innerObservableSource
s till all of them terminate.Note that there is no guarantee where the given
mapper
function will be executed; it could be on the subscribing thread, on the upstream thread signaling the new item to be mapped or on the thread where the inner source terminates. To ensure themapper
function is confined to a known thread, use theconcatMapDelayError(Function, boolean, int, Scheduler)
overload.- Scheduler:
concatMapDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the result value type- Parameters:
mapper
- the function that maps the items of the currentObservable
into the innerObservableSource
s.tillTheEnd
- iftrue
, all errors from the outer and innerObservableSource
sources are delayed until the end, iffalse
, an error from the main source is signaled when the currentObservable
source terminatesbufferSize
- the number of elements expected from the currentObservable
to be buffered- Returns:
- the new
Observable
instance with the concatenation behavior - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
concatMapDelayError(Function, boolean, int, Scheduler)
-
concatMapDelayError
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, boolean tillTheEnd, int bufferSize, @NonNull @NonNull Scheduler scheduler)
Maps each of the items into anObservableSource
, subscribes to them one after the other, one at a time and emits their values in order while delaying any error from either this or any of the innerObservableSource
s till all of them terminate.- Scheduler:
concatMapDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the result value type- Parameters:
mapper
- the function that maps the items of the currentObservable
into the innerObservableSource
s.tillTheEnd
- iftrue
, all errors from the outer and innerObservableSource
sources are delayed until the end, iffalse
, an error from the main source is signaled when the currentObservable
source terminatesbufferSize
- the number of elements expected from the currentObservable
to be bufferedscheduler
- the scheduler where themapper
function will be executed- Returns:
- the new
Observable
instance with the concatenation behavior - Throws:
java.lang.NullPointerException
- ifmapper
orscheduler
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 3.0.0
- See Also:
concatMapDelayError(Function, boolean, int)
-
concatMapEager
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapEager(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper)
Maps a sequence of values intoObservableSource
s and concatenates theseObservableSource
s eagerly into a singleObservable
sequence.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the current
Observable
s. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
R
- the value type- Parameters:
mapper
- the function that maps a sequence of values into a sequence ofObservableSource
s that will be eagerly concatenated- Returns:
- the new
Observable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.0
-
concatMapEager
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapEager(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, int maxConcurrency, int bufferSize)
Maps a sequence of values intoObservableSource
s and concatenates theseObservableSource
s eagerly into a singleObservable
sequence.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the current
Observable
s. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
R
- the value type- Parameters:
mapper
- the function that maps a sequence of values into a sequence ofObservableSource
s that will be eagerly concatenatedmaxConcurrency
- the maximum number of concurrent subscribedObservableSource
sbufferSize
- hints about the number of expected items from each innerObservableSource
, must be positive- Returns:
- the new
Observable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- Since:
- 2.0
-
concatMapEagerDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapEagerDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, boolean tillTheEnd)
Maps a sequence of values intoObservableSource
s and concatenates theseObservableSource
s eagerly into a singleObservable
sequence.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the current
Observable
s. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
R
- the value type- Parameters:
mapper
- the function that maps a sequence of values into a sequence ofObservableSource
s that will be eagerly concatenatedtillTheEnd
- iftrue
, all errors from the outer and innerObservableSource
sources are delayed until the end, iffalse
, an error from the main source is signaled when the currentObservable
source terminates- Returns:
- the new
Observable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.0
-
concatMapEagerDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapEagerDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, boolean tillTheEnd, int maxConcurrency, int bufferSize)
Maps a sequence of values intoObservableSource
s and concatenates theseObservableSource
s eagerly into a singleObservable
sequence.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the current
Observable
s. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
R
- the value type- Parameters:
mapper
- the function that maps a sequence of values into a sequence ofObservableSource
s that will be eagerly concatenatedtillTheEnd
- iftrue
, exceptions from the currentObservable
and all the innerObservableSource
s are delayed until all of them terminate, iffalse
, exception from the currentObservable
is delayed until the currently runningObservableSource
terminatesmaxConcurrency
- the maximum number of concurrent subscribedObservableSource
sbufferSize
- the number of elements expected from the currentObservable
and each innerObservableSource
to be buffered- Returns:
- the new
Observable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- Since:
- 2.0
-
concatMapCompletable
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Completable concatMapCompletable(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps each element of the currentObservable
intoCompletableSource
s, subscribes to them one at a time in order and waits until the upstream and allCompletableSource
s complete.- Scheduler:
concatMapCompletable
does not operate by default on a particularScheduler
.
History: 2.1.6 - experimental
- Parameters:
mapper
- a function that, when applied to an item emitted by the currentObservable
, returns aCompletableSource
- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
-
concatMapCompletable
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Completable concatMapCompletable(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper, int capacityHint)
Maps each element of the currentObservable
intoCompletableSource
s, subscribes to them one at a time in order and waits until the upstream and allCompletableSource
s complete.- Scheduler:
concatMapCompletable
does not operate by default on a particularScheduler
.
History: 2.1.6 - experimental
- Parameters:
mapper
- a function that, when applied to an item emitted by the currentObservable
, returns aCompletableSource
capacityHint
- the number of upstream items expected to be buffered until the currentCompletableSource
, mapped from the current item, completes.- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifcapacityHint
is non-positive- Since:
- 2.2
-
concatMapCompletableDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Completable concatMapCompletableDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps the upstream items intoCompletableSource
s and subscribes to them one after the other terminates, delaying all errors till both the currentObservable
and all innerCompletableSource
s terminate.- Scheduler:
concatMapCompletableDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Parameters:
mapper
- the function called with the upstream item and should return aCompletableSource
to become the next source to be subscribed to- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
concatMapCompletable(Function, int)
-
concatMapCompletableDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Completable concatMapCompletableDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper, boolean tillTheEnd)
Maps the upstream items intoCompletableSource
s and subscribes to them one after the other terminates, optionally delaying all errors till both the currentObservable
and all innerCompletableSource
s terminate.- Scheduler:
concatMapCompletableDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Parameters:
mapper
- the function called with the upstream item and should return aCompletableSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from the currentObservable
or any of the innerCompletableSource
s are delayed until all of them terminate. Iffalse
, an error from the currentObservable
is delayed until the current innerCompletableSource
terminates and only then is it emitted to the downstream.- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
concatMapCompletable(Function)
-
concatMapCompletableDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Completable concatMapCompletableDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper, boolean tillTheEnd, int bufferSize)
Maps the upstream items intoCompletableSource
s and subscribes to them one after the other terminates, optionally delaying all errors till both the currentObservable
and all innerCompletableSource
s terminate.- Scheduler:
concatMapCompletableDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Parameters:
mapper
- the function called with the upstream item and should return aCompletableSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from the currentObservable
or any of the innerCompletableSource
s are delayed until all of them terminate. Iffalse
, an error from the currentObservable
is delayed until the current innerCompletableSource
terminates and only then is it emitted to the downstream.bufferSize
- The number of upstream items expected to be buffered so that fresh items are ready to be mapped when a previousCompletableSource
terminates.- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 2.2
- See Also:
concatMapCompletable(Function, int)
-
concatMapIterable
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U> @NonNull Observable<U> concatMapIterable(@NonNull @NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper)
Returns anObservable
that concatenate each item emitted by the currentObservable
with the values in anIterable
corresponding to that item that is generated by a selector.- Scheduler:
concatMapIterable
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of item emitted by the resultingObservable
- Parameters:
mapper
- a function that returns anIterable
sequence of values for when given an item emitted by the currentObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- See Also:
- ReactiveX operators documentation: FlatMap
-
concatMapMaybe
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapMaybe(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other succeeds or completes, emits their success value if available or terminates immediately if either the currentObservable
or the current innerMaybeSource
fail.- Scheduler:
concatMapMaybe
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerMaybeSource
s- Parameters:
mapper
- the function called with the upstream item and should return aMaybeSource
to become the next source to be subscribed to- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
concatMapMaybeDelayError(Function)
,concatMapMaybe(Function, int)
-
concatMapMaybe
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapMaybe(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper, int bufferSize)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other succeeds or completes, emits their success value if available or terminates immediately if either the currentObservable
or the current innerMaybeSource
fail.- Scheduler:
concatMapMaybe
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerMaybeSource
s- Parameters:
mapper
- the function called with the upstream item and should return aMaybeSource
to become the next source to be subscribed tobufferSize
- The number of upstream items expected to be buffered so that fresh items are ready to be mapped when a previousMaybeSource
terminates.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 2.2
- See Also:
concatMapMaybe(Function)
,concatMapMaybeDelayError(Function, boolean, int)
-
concatMapMaybeDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapMaybeDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other terminates, emits their success value if available and delaying all errors till both the currentObservable
and all innerMaybeSource
s terminate.- Scheduler:
concatMapMaybeDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerMaybeSource
s- Parameters:
mapper
- the function called with the upstream item and should return aMaybeSource
to become the next source to be subscribed to- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
concatMapMaybe(Function)
,concatMapMaybeDelayError(Function, boolean)
-
concatMapMaybeDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapMaybeDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper, boolean tillTheEnd)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other terminates, emits their success value if available and optionally delaying all errors till both the currentObservable
and all innerMaybeSource
s terminate.- Scheduler:
concatMapMaybeDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerMaybeSource
s- Parameters:
mapper
- the function called with the upstream item and should return aMaybeSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from the currentObservable
or any of the innerMaybeSource
s are delayed until all of them terminate. Iffalse
, an error from the currentObservable
is delayed until the current innerMaybeSource
terminates and only then is it emitted to the downstream.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
concatMapMaybe(Function, int)
,concatMapMaybeDelayError(Function, boolean, int)
-
concatMapMaybeDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapMaybeDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper, boolean tillTheEnd, int bufferSize)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other terminates, emits their success value if available and optionally delaying all errors till both the currentObservable
and all innerMaybeSource
s terminate.- Scheduler:
concatMapMaybeDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerMaybeSource
s- Parameters:
mapper
- the function called with the upstream item and should return aMaybeSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from the currentObservable
or any of the innerMaybeSource
s are delayed until all of them terminate. Iffalse
, an error from the currentObservable
is delayed until the current innerMaybeSource
terminates and only then is it emitted to the downstream.bufferSize
- The number of upstream items expected to be buffered so that fresh items are ready to be mapped when a previousMaybeSource
terminates.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 2.2
- See Also:
concatMapMaybe(Function, int)
-
concatMapSingle
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapSingle(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds, emits their success values or terminates immediately if either the currentObservable
or the current innerSingleSource
fail.- Scheduler:
concatMapSingle
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerSingleSource
s- Parameters:
mapper
- the function called with the upstream item and should return aSingleSource
to become the next source to be subscribed to- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
concatMapSingleDelayError(Function)
,concatMapSingle(Function, int)
-
concatMapSingle
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapSingle(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper, int bufferSize)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds, emits their success values or terminates immediately if either the currentObservable
or the current innerSingleSource
fail.- Scheduler:
concatMapSingle
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerSingleSource
s- Parameters:
mapper
- the function called with the upstream item and should return aSingleSource
to become the next source to be subscribed tobufferSize
- The number of upstream items expected to be buffered so that fresh items are ready to be mapped when a previousSingleSource
terminates.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 2.2
- See Also:
concatMapSingle(Function)
,concatMapSingleDelayError(Function, boolean, int)
-
concatMapSingleDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapSingleDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds or fails, emits their success values and delays all errors till both the currentObservable
and all innerSingleSource
s terminate.- Scheduler:
concatMapSingleDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerSingleSource
s- Parameters:
mapper
- the function called with the upstream item and should return aSingleSource
to become the next source to be subscribed to- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
concatMapSingle(Function)
,concatMapSingleDelayError(Function, boolean)
-
concatMapSingleDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapSingleDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper, boolean tillTheEnd)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds or fails, emits their success values and optionally delays all errors till both the currentObservable
and all innerSingleSource
s terminate.- Scheduler:
concatMapSingleDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerSingleSource
s- Parameters:
mapper
- the function called with the upstream item and should return aSingleSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from the currentObservable
or any of the innerSingleSource
s are delayed until all of them terminate. Iffalse
, an error from the currentObservable
is delayed until the current innerSingleSource
terminates and only then is it emitted to the downstream.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
concatMapSingle(Function, int)
,concatMapSingleDelayError(Function, boolean, int)
-
concatMapSingleDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapSingleDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper, boolean tillTheEnd, int bufferSize)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds or fails, emits their success values and optionally delays errors till both the currentObservable
and all innerSingleSource
s terminate.- Scheduler:
concatMapSingleDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerSingleSource
s- Parameters:
mapper
- the function called with the upstream item and should return aSingleSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from the currentObservable
or any of the innerSingleSource
s are delayed until all of them terminate. Iffalse
, an error from the currentObservable
is delayed until the current innerSingleSource
terminates and only then is it emitted to the downstream.bufferSize
- The number of upstream items expected to be buffered so that fresh items are ready to be mapped when a previousSingleSource
terminates.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 2.2
- See Also:
concatMapSingle(Function, int)
-
concatWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> concatWith(@NonNull @NonNull ObservableSource<? extends @NonNull T> other)
Returns anObservable
that first emits the items emitted from the currentObservable
, then items from theother
ObservableSource
without interleaving them.- Scheduler:
concatWith
does not operate by default on a particularScheduler
.
- Parameters:
other
- anObservableSource
to be concatenated after the current- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- See Also:
- ReactiveX operators documentation: Concat
-
concatWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> concatWith(@NonNull @NonNull SingleSource<? extends @NonNull T> other)
Returns anObservable
that emits the items from the currentObservable
followed by the success item or error event of theother
SingleSource
.- Scheduler:
concatWith
does not operate by default on a particularScheduler
.
History: 2.1.10 - experimental
- Parameters:
other
- theSingleSource
whose signal should be emitted after the currentObservable
completes normally.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 2.2
-
concatWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> concatWith(@NonNull @NonNull MaybeSource<? extends @NonNull T> other)
Returns anObservable
that emits the items from the currentObservable
followed by the success item or terminal events of the otherMaybeSource
.- Scheduler:
concatWith
does not operate by default on a particularScheduler
.
History: 2.1.10 - experimental
- Parameters:
other
- theMaybeSource
whose signal should be emitted after the currentObservable
completes normally.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 2.2
-
concatWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> concatWith(@NonNull @NonNull CompletableSource other)
Returns anObservable
that emits items from the currentObservable
and when it completes normally, the otherCompletableSource
is subscribed to and the returnedObservable
emits its terminal events.- Scheduler:
concatWith
does not operate by default on a particularScheduler
.
History: 2.1.10 - experimental
- Parameters:
other
- theCompletableSource
to subscribe to once the currentObservable
completes normally- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 2.2
-
contains
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<java.lang.Boolean> contains(@NonNull @NonNull java.lang.Object item)
Returns aSingle
that emits aBoolean
that indicates whether the currentObservable
emitted a specified item.- Scheduler:
contains
does not operate by default on a particularScheduler
.
- Parameters:
item
- the item to search for in the emissions from the currentObservable
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifitem
isnull
- See Also:
- ReactiveX operators documentation: Contains
-
count
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<java.lang.Long> count()
Returns aSingle
that counts the total number of items emitted by the currentObservable
and emits this count as a 64-bitLong
.- Scheduler:
count
does not operate by default on a particularScheduler
.
- Returns:
- the new
Single
instance - See Also:
- ReactiveX operators documentation: Count
-
debounce
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U> @NonNull Observable<T> debounce(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull U>> debounceIndicator)
Returns anObservable
that mirrors the currentObservable
, except that it drops items emitted by the currentObservable
that are followed by another item within a computed debounce duration denoted by an item emission or completion from a generated innerObservableSource
for that original item.The delivery of the item happens on the thread of the first
onNext
oronComplete
signal of the generatedObservableSource
sequence, which if takes too long, a newer item may arrive from the upstream, causing the generated sequence to get disposed, which may also interrupt any downstream blocking operation (yielding anInterruptedException
). It is recommended processing items that may take long time to be moved to another thread viaobserveOn(io.reactivex.rxjava3.core.Scheduler)
applied afterdebounce
itself.- Scheduler:
- This version of
debounce
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the debounce value type (ignored)- Parameters:
debounceIndicator
- function to return a sequence that indicates the throttle duration for each item via its own emission or completion- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifdebounceIndicator
isnull
- See Also:
- ReactiveX operators documentation: Debounce
-
debounce
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<T> debounce(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that mirrors the currentObservable
, except that it drops items emitted by the currentObservable
that are followed by newer items before a timeout value expires. The timer resets on each emission.Note: If items keep being emitted by the current
Observable
faster than the timeout then no items will be emitted by the resultingObservable
.Delivery of the item after the grace period happens on the
computation
Scheduler
'sWorker
which if takes too long, a newer item may arrive from the upstream, causing theWorker
's task to get disposed, which may also interrupt any downstream blocking operation (yielding anInterruptedException
). It is recommended processing items that may take long time to be moved to another thread viaobserveOn(io.reactivex.rxjava3.core.Scheduler)
applied afterdebounce
itself.- Scheduler:
debounce
operates by default on thecomputation
Scheduler
.
- Parameters:
timeout
- the length of the window of time that must pass after the emission of an item from the currentObservable
in which theObservable
emits no items in order for the item to be emitted by the resultingObservable
unit
- the unit of time for the specifiedtimeout
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Debounce,
throttleWithTimeout(long, TimeUnit)
-
debounce
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> debounce(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that mirrors the currentObservable
, except that it drops items emitted by the currentObservable
that are followed by newer items before a timeout value expires on a specifiedScheduler
. The timer resets on each emission.Note: If items keep being emitted by the current
Observable
faster than the timeout then no items will be emitted by the resultingObservable
.Delivery of the item after the grace period happens on the given
Scheduler
'sWorker
which if takes too long, a newer item may arrive from the upstream, causing theWorker
's task to get disposed, which may also interrupt any downstream blocking operation (yielding anInterruptedException
). It is recommended processing items that may take long time to be moved to another thread viaobserveOn(io.reactivex.rxjava3.core.Scheduler)
applied afterdebounce
itself.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timeout
- the time each item has to be "the most recent" of those emitted by the currentObservable
to ensure that it's not droppedunit
- the unit of time for the specifiedtimeout
scheduler
- theScheduler
to use internally to manage the timers that handle the timeout for each item- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Debounce,
throttleWithTimeout(long, TimeUnit, Scheduler)
-
debounce
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> debounce(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, @NonNull @NonNull Consumer<? super @NonNull T> onDropped)
Returns anObservable
that mirrors the currentObservable
, except that it drops items emitted by the currentObservable
that are followed by newer items before a timeout value expires on a specifiedScheduler
. The timer resets on each emission.Note: If items keep being emitted by the current
Observable
faster than the timeout then no items will be emitted by the resultingObservable
.Delivery of the item after the grace period happens on the given
Scheduler
'sWorker
which if takes too long, a newer item may arrive from the upstream, causing theWorker
's task to get disposed, which may also interrupt any downstream blocking operation (yielding anInterruptedException
). It is recommended processing items that may take long time to be moved to another thread viaobserveOn(io.reactivex.rxjava3.core.Scheduler)
applied afterdebounce
itself.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timeout
- the time each item has to be "the most recent" of those emitted by the currentObservable
to ensure that it's not droppedunit
- the unit of time for the specifiedtimeout
scheduler
- theScheduler
to use internally to manage the timers that handle the timeout for each itemonDropped
- called with the current entry when it has been replaced by a new one- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
} oronDropped
isnull
- Since:
- 3.1.6 - Experimental
- See Also:
- ReactiveX operators documentation: Debounce,
throttleWithTimeout(long, TimeUnit, Scheduler, Consumer)
-
defaultIfEmpty
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> defaultIfEmpty(@NonNull @NonNull T defaultItem)
Returns anObservable
that emits the items emitted by the currentObservable
or a specified default item if the currentObservable
is empty.- Scheduler:
defaultIfEmpty
does not operate by default on a particularScheduler
.
- Parameters:
defaultItem
- the item to emit if the currentObservable
emits no items- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
- See Also:
- ReactiveX operators documentation: DefaultIfEmpty
-
delay
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U> @NonNull Observable<T> delay(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull U>> itemDelayIndicator)
Returns anObservable
that delays the emissions of the currentObservable
via a per-item derivedObservableSource
's item emission or termination, on a per source item basis.Note: the resulting
Observable
will immediately propagate anyonError
notification from the currentObservable
.- Scheduler:
- This version of
delay
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the item delay value type (ignored)- Parameters:
itemDelayIndicator
- a function that returns anObservableSource
for each item emitted by the currentObservable
, which is then used to delay the emission of that item by the resultingObservable
until theObservableSource
returned fromitemDelay
emits an item- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitemDelayIndicator
isnull
- See Also:
- ReactiveX operators documentation: Delay
-
delay
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<T> delay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits the items emitted by the currentObservable
shifted forward in time by a specified delay. An error notification from the currentObservable
is not delayed.- Scheduler:
- This version of
delay
operates by default on thecomputation
Scheduler
.
- Parameters:
time
- the delay to shift the source byunit
- theTimeUnit
in whichperiod
is defined- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Delay,
delay(long, TimeUnit, boolean)
,delay(long, TimeUnit, Scheduler)
-
delay
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<T> delay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, boolean delayError)
Returns anObservable
that emits the items emitted by the currentObservable
shifted forward in time by a specified delay. IfdelayError
istrue
, error notifications will also be delayed.- Scheduler:
- This version of
delay
operates by default on thecomputation
Scheduler
.
- Parameters:
time
- the delay to shift the source byunit
- theTimeUnit
in whichperiod
is defineddelayError
- iftrue
, the upstream exception is signaled with the given delay, after all preceding normal elements, iffalse
, the upstream exception is signaled immediately- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Delay,
delay(long, TimeUnit, Scheduler, boolean)
-
delay
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> delay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits the items emitted by the currentObservable
shifted forward in time by a specified delay. An error notification from the currentObservable
is not delayed.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the delay to shift the source byunit
- the time unit ofdelay
scheduler
- theScheduler
to use for delaying- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Delay
-
delay
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> delay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean delayError)
Returns anObservable
that emits the items emitted by the currentObservable
shifted forward in time by a specified delay. IfdelayError
istrue
, error notifications will also be delayed.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the delay to shift the source byunit
- the time unit ofdelay
scheduler
- theScheduler
to use for delayingdelayError
- iftrue
, the upstream exception is signaled with the given delay, after all preceding normal elements, iffalse
, the upstream exception is signaled immediately- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Delay
-
delay
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull V> @NonNull Observable<T> delay(@NonNull @NonNull ObservableSource<@NonNull U> subscriptionIndicator, @NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull V>> itemDelayIndicator)
Returns anObservable
that delays the subscription to and emissions from the currentObservable
viaObservableSource
s for the subscription itself and on a per-item basis.Note: the resulting
Observable
will immediately propagate anyonError
notification from the currentObservable
.- Scheduler:
- This version of
delay
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the subscription delay value type (ignored)V
- the item delay value type (ignored)- Parameters:
subscriptionIndicator
- a function that returns anObservableSource
that triggers the subscription to the currentObservable
once it emits any itemitemDelayIndicator
- a function that returns anObservableSource
for each item emitted by the currentObservable
, which is then used to delay the emission of that item by the resultingObservable
until theObservableSource
returned fromitemDelay
emits an item- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsubscriptionIndicator
oritemDelayIndicator
isnull
- See Also:
- ReactiveX operators documentation: Delay
-
delaySubscription
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U> @NonNull Observable<T> delaySubscription(@NonNull @NonNull ObservableSource<@NonNull U> subscriptionIndicator)
Returns anObservable
that delays the subscription to the currentObservable
until the otherObservableSource
emits an element or completes normally.- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
U
- the value type of the otherObservable
, irrelevant- Parameters:
subscriptionIndicator
- the otherObservableSource
that should trigger the subscription to the currentObservable
.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsubscriptionIndicator
isnull
- Since:
- 2.0
-
delaySubscription
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<T> delaySubscription(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that delays the subscription to the currentObservable
by a given amount of time.- Scheduler:
- This version of
delaySubscription
operates by default on thecomputation
Scheduler
.
- Parameters:
time
- the time to delay the subscriptionunit
- the time unit ofdelay
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Delay
-
delaySubscription
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> delaySubscription(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that delays the subscription to the currentObservable
by a given amount of time, both waiting and subscribing on a givenScheduler
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the time to delay the subscriptionunit
- the time unit ofdelay
scheduler
- theScheduler
on which the waiting and subscription will happen- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Delay
-
dematerialize
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> dematerialize(@NonNull @NonNull Function<? super @NonNull T,Notification<@NonNull R>> selector)
Returns anObservable
that reverses the effect ofmaterialize
by transforming theNotification
objects extracted from the source items via a selector function into their respectiveObserver
signal types.The intended use of the
selector
function is to perform a type-safe identity mapping (see example) on a source that is already of typeNotification<T>
. The Java language doesn't allow limiting instance methods to a certain generic argument shape, therefore, a function is used to ensure the conversion remains type safe.When the upstream signals an
onError
oronComplete
item, the returnedObservable
disposes of the flow and terminates with that type of terminal event:
If the upstream signalsObservable.just(createOnNext(1), createOnComplete(), createOnNext(2)) .doOnDispose(() -> System.out.println("Disposed!")); .dematerialize(notification -> notification) .test() .assertResult(1);
onError
oronComplete
directly, the flow is terminated with the same event.
If this behavior is not desired, the completion can be suppressed by applyingObservable.just(createOnNext(1), createOnNext(2)) .dematerialize(notification -> notification) .test() .assertResult(1, 2);
concatWith(ObservableSource)
with anever()
source.- Scheduler:
dematerialize
does not operate by default on a particularScheduler
.
History: 2.2.4 - experimental
- Type Parameters:
R
- the output value type- Parameters:
selector
- function that returns the upstream item and should return aNotification
to signal the correspondingObserver
event to the downstream.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifselector
isnull
- Since:
- 3.0.0
- See Also:
- ReactiveX operators documentation: Dematerialize
-
distinct
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> distinct()
Returns anObservable
that emits all items emitted by the currentObservable
that are distinct based onObject.equals(Object)
comparison.It is recommended the elements' class
T
in the flow overrides the defaultObject.equals()
andObject.hashCode()
to provide meaningful comparison between items as the default Java implementation only considers reference equivalence.By default,
distinct()
uses an internalHashSet
perObserver
to remember previously seen items and usesSet.add(Object)
returningfalse
as the indicator for duplicates.Note that this internal
HashSet
may grow unbounded as items won't be removed from it by the operator. Therefore, using very long or infinite upstream (with very distinct elements) may lead toOutOfMemoryError
.Customizing the retention policy can happen only by providing a custom
Collection
implementation to thedistinct(Function, Supplier)
overload.- Scheduler:
distinct
does not operate by default on a particularScheduler
.
- Returns:
- the new
Observable
instance - See Also:
- ReactiveX operators documentation: Distinct,
distinct(Function)
,distinct(Function, Supplier)
-
distinct
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull K> @NonNull Observable<T> distinct(@NonNull @NonNull Function<? super @NonNull T,@NonNull K> keySelector)
Returns anObservable
that emits all items emitted by the currentObservable
that are distinct according to a key selector function and based onObject.equals(Object)
comparison of the objects returned by the key selector function.It is recommended the keys' class
K
overrides the defaultObject.equals()
andObject.hashCode()
to provide meaningful comparison between the key objects as the default Java implementation only considers reference equivalence.By default,
distinct()
uses an internalHashSet
perObserver
to remember previously seen keys and usesSet.add(Object)
returningfalse
as the indicator for duplicates.Note that this internal
HashSet
may grow unbounded as keys won't be removed from it by the operator. Therefore, using very long or infinite upstream (with very distinct keys) may lead toOutOfMemoryError
.Customizing the retention policy can happen only by providing a custom
Collection
implementation to thedistinct(Function, Supplier)
overload.- Scheduler:
distinct
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type- Parameters:
keySelector
- a function that projects an emitted item to a key value that is used to decide whether an item is distinct from another one or not- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
isnull
- See Also:
- ReactiveX operators documentation: Distinct,
distinct(Function, Supplier)
-
distinct
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull K> @NonNull Observable<T> distinct(@NonNull @NonNull Function<? super @NonNull T,@NonNull K> keySelector, @NonNull @NonNull Supplier<? extends java.util.Collection<? super @NonNull K>> collectionSupplier)
Returns anObservable
that emits all items emitted by the currentObservable
that are distinct according to a key selector function and based onObject.equals(Object)
comparison of the objects returned by the key selector function.It is recommended the keys' class
K
overrides the defaultObject.equals()
andObject.hashCode()
to provide meaningful comparison between the key objects as the default Java implementation only considers reference equivalence.- Scheduler:
distinct
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type- Parameters:
keySelector
- a function that projects an emitted item to a key value that is used to decide whether an item is distinct from another one or notcollectionSupplier
- function called for each individualObserver
to return aCollection
subtype for holding the extracted keys and whoseadd()
method's return indicates uniqueness.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
orcollectionSupplier
isnull
- See Also:
- ReactiveX operators documentation: Distinct
-
distinctUntilChanged
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> distinctUntilChanged()
Returns anObservable
that emits all items emitted by the currentObservable
that are distinct from their immediate predecessors based onObject.equals(Object)
comparison.It is recommended the elements' class
T
in the flow overrides the defaultObject.equals()
to provide meaningful comparison between items as the default Java implementation only considers reference equivalence. Alternatively, use thedistinctUntilChanged(BiPredicate)
overload and provide a comparison function in case the classT
can't be overridden with customequals()
or the comparison itself should happen on different terms or properties of the classT
.Note that the operator always retains the latest item from upstream regardless of the comparison result and uses it in the next comparison with the next upstream item.
Note that if element type
T
in the flow is mutable, the comparison of the previous and current item may yield unexpected results if the items are mutated externally. Common cases are mutableCharSequence
s orList
s where the objects will actually have the same references when they are modified anddistinctUntilChanged
will evaluate subsequent items as same. To avoid such situation, it is recommended that mutable data is converted to an immutable one, for example usingmap(CharSequence::toString)
ormap(list -> Collections.unmodifiableList(new ArrayList<>(list)))
.- Scheduler:
distinctUntilChanged
does not operate by default on a particularScheduler
.
- Returns:
- the new
Observable
instance - See Also:
- ReactiveX operators documentation: Distinct,
distinctUntilChanged(BiPredicate)
-
distinctUntilChanged
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull K> @NonNull Observable<T> distinctUntilChanged(@NonNull @NonNull Function<? super @NonNull T,@NonNull K> keySelector)
Returns anObservable
that emits all items emitted by the currentObservable
that are distinct from their immediate predecessors, according to a key selector function and based onObject.equals(Object)
comparison of those objects returned by the key selector function.It is recommended the keys' class
K
overrides the defaultObject.equals()
to provide meaningful comparison between the key objects as the default Java implementation only considers reference equivalence. Alternatively, use thedistinctUntilChanged(BiPredicate)
overload and provide a comparison function in case the classK
can't be overridden with customequals()
or the comparison itself should happen on different terms or properties of the item classT
(for which the keys can be derived via a similar selector).Note that the operator always retains the latest key from upstream regardless of the comparison result and uses it in the next comparison with the next key derived from the next upstream item.
Note that if element type
T
in the flow is mutable, the comparison of the previous and current item may yield unexpected results if the items are mutated externally. Common cases are mutableCharSequence
s orList
s where the objects will actually have the same references when they are modified anddistinctUntilChanged
will evaluate subsequent items as same. To avoid such situation, it is recommended that mutable data is converted to an immutable one, for example usingmap(CharSequence::toString)
ormap(list -> Collections.unmodifiableList(new ArrayList<>(list)))
.- Scheduler:
distinctUntilChanged
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type- Parameters:
keySelector
- a function that projects an emitted item to a key value that is used to decide whether an item is distinct from another one or not- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
isnull
- See Also:
- ReactiveX operators documentation: Distinct
-
distinctUntilChanged
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> distinctUntilChanged(@NonNull @NonNull BiPredicate<? super @NonNull T,? super @NonNull T> comparer)
Returns anObservable
that emits all items emitted by the currentObservable
that are distinct from their immediate predecessors when compared with each other via the provided comparator function.Note that the operator always retains the latest item from upstream regardless of the comparison result and uses it in the next comparison with the next upstream item.
Note that if element type
T
in the flow is mutable, the comparison of the previous and current item may yield unexpected results if the items are mutated externally. Common cases are mutableCharSequence
s orList
s where the objects will actually have the same references when they are modified anddistinctUntilChanged
will evaluate subsequent items as same. To avoid such situation, it is recommended that mutable data is converted to an immutable one, for example usingmap(CharSequence::toString)
ormap(list -> Collections.unmodifiableList(new ArrayList<>(list)))
.- Scheduler:
distinctUntilChanged
does not operate by default on a particularScheduler
.
- Parameters:
comparer
- the function that receives the previous item and the current item and is expected to returntrue
if the two are equal, thus skipping the current value.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifcomparer
isnull
- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: Distinct
-
doAfterNext
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> doAfterNext(@NonNull @NonNull Consumer<? super @NonNull T> onAfterNext)
Calls the specifiedConsumer
with the current item after this item has been emitted to the downstream.Note that the
onAfterNext
action is shared between subscriptions and as such should be thread-safe.- Scheduler:
doAfterNext
does not operate by default on a particularScheduler
.- Operator-fusion:
- This operator supports boundary-limited synchronous or asynchronous queue-fusion.
History: 2.0.1 - experimental
- Parameters:
onAfterNext
- theConsumer
that will be called after emitting an item from upstream to the downstream- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifonAfterNext
isnull
- Since:
- 2.1
-
doAfterTerminate
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> doAfterTerminate(@NonNull @NonNull Action onAfterTerminate)
Registers anAction
to be called when the currentObservable
invokes eitheronComplete
oronError
.- Scheduler:
doAfterTerminate
does not operate by default on a particularScheduler
.
- Parameters:
onAfterTerminate
- anAction
to be invoked after the currentObservable
finishes- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifonAfterTerminate
isnull
- See Also:
- ReactiveX operators documentation: Do,
doOnTerminate(Action)
-
doFinally
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> doFinally(@NonNull @NonNull Action onFinally)
Calls the specified action after the currentObservable
signalsonError
oronCompleted
or gets disposed by the downstream.In case of a race between a terminal event and a dispose call, the provided
onFinally
action is executed once per subscription.Note that the
onFinally
action is shared between subscriptions and as such should be thread-safe.- Scheduler:
doFinally
does not operate by default on a particularScheduler
.- Operator-fusion:
- This operator supports boundary-limited synchronous or asynchronous queue-fusion.
History: 2.0.1 - experimental
- Parameters:
onFinally
- the action called when the currentObservable
terminates or gets disposed- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifonFinally
isnull
- Since:
- 2.1
-
doOnDispose
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> doOnDispose(@NonNull @NonNull Action onDispose)
Calls the given sharedAction
if the downstream disposes the sequence.The action is shared between subscriptions and thus may be called concurrently from multiple threads; the action must be thread safe.
If the action throws a runtime exception, that exception is rethrown by the
dispose()
call, sometimes as aCompositeException
if there were multiple exceptions along the way.- Scheduler:
doOnDispose
does not operate by default on a particularScheduler
.
- Parameters:
onDispose
- the action that gets called when the currentObservable
'sDisposable
is disposed- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifonDispose
isnull
- See Also:
- ReactiveX operators documentation: Do
-
doOnComplete
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> doOnComplete(@NonNull @NonNull Action onComplete)
Returns anObservable
that invokes anAction
when the currentObservable
callsonComplete
.- Scheduler:
doOnComplete
does not operate by default on a particularScheduler
.
- Parameters:
onComplete
- the action to invoke when the currentObservable
callsonComplete
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifonComplete
isnull
- See Also:
- ReactiveX operators documentation: Do
-
doOnEach
@CheckReturnValue @SchedulerSupport("none") @NonNull private @NonNull Observable<T> doOnEach(@NonNull @NonNull Consumer<? super @NonNull T> onNext, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull @NonNull Action onComplete, @NonNull @NonNull Action onAfterTerminate)
Calls the appropriateonXXX
consumer (shared between allObserver
s) whenever a signal with the same type passes through, before forwarding them to the downstream.- Scheduler:
doOnEach
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- theConsumer
to invoke when the currentObservable
callsonNext
onError
- theConsumer
to invoke when the currentObservable
callsonError
onComplete
- theAction
to invoke when the currentObservable
callsonComplete
onAfterTerminate
- theAction
to invoke when the currentObservable
callsonAfterTerminate
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifonNext
,onError
,onComplete
oronAfterTerminate
isnull
- See Also:
- ReactiveX operators documentation: Do
-
doOnEach
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> doOnEach(@NonNull @NonNull Consumer<? super Notification<@NonNull T>> onNotification)
Returns anObservable
that invokes aConsumer
with the appropriateNotification
object when the currentObservable
signals an item or terminates.- Scheduler:
doOnEach
does not operate by default on a particularScheduler
.
- Parameters:
onNotification
- the action to invoke for each item emitted by the currentObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifonNotification
isnull
- See Also:
- ReactiveX operators documentation: Do
-
doOnEach
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> doOnEach(@NonNull @NonNull Observer<? super @NonNull T> observer)
Returns anObservable
that forwards the items and terminal events of the currentObservable
to itsObserver
s and to the given sharedObserver
instance.In case the
onError
of the supplied observer throws, the downstream will receive a composite exception containing the original exception and the exception thrown byonError
. If either theonNext
or theonComplete
method of the supplied observer throws, the downstream will be terminated and will receive this thrown exception.- Scheduler:
doOnEach
does not operate by default on a particularScheduler
.
- Parameters:
observer
- the observer to be notified aboutonNext
,onError
andonComplete
events on its respective methods before the actual downstreamObserver
gets notified.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifobserver
isnull
- See Also:
- ReactiveX operators documentation: Do
-
doOnError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> doOnError(@NonNull @NonNull Consumer<? super java.lang.Throwable> onError)
Calls the givenConsumer
with the errorThrowable
if the currentObservable
failed before forwarding it to the downstream.In case the
onError
action throws, the downstream will receive a composite exception containing the original exception and the exception thrown byonError
.- Scheduler:
doOnError
does not operate by default on a particularScheduler
.
- Parameters:
onError
- the action to invoke if the currentObservable
callsonError
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifonError
isnull
- See Also:
- ReactiveX operators documentation: Do
-
doOnLifecycle
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> doOnLifecycle(@NonNull @NonNull Consumer<? super Disposable> onSubscribe, @NonNull @NonNull Action onDispose)
Calls the appropriateonXXX
method (shared between allObserver
s) for the lifecycle events of the sequence (subscription, disposal).- Scheduler:
doOnLifecycle
does not operate by default on a particularScheduler
.
- Parameters:
onSubscribe
- aConsumer
called with theDisposable
sent viaObserver.onSubscribe(Disposable)
onDispose
- called when the downstream disposes theDisposable
viadispose()
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifonSubscribe
oronDispose
isnull
- See Also:
- ReactiveX operators documentation: Do
-
doOnNext
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> doOnNext(@NonNull @NonNull Consumer<? super @NonNull T> onNext)
Calls the givenConsumer
with the value emitted by the currentObservable
before forwarding it to the downstream.- Scheduler:
doOnNext
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- the action to invoke when the currentObservable
callsonNext
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifonNext
isnull
- See Also:
- ReactiveX operators documentation: Do
-
doOnSubscribe
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> doOnSubscribe(@NonNull @NonNull Consumer<? super Disposable> onSubscribe)
Returns anObservable
so that it invokes the givenConsumer
when the currentObservable
is subscribed from itsObserver
s. Each subscription will result in an invocation of the given action except when the currentObservable
is reference counted, in which case the currentObservable
will invoke the given action for the first subscription.- Scheduler:
doOnSubscribe
does not operate by default on a particularScheduler
.
- Parameters:
onSubscribe
- theConsumer
that gets called when anObserver
subscribes to the currentObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifonSubscribe
isnull
- See Also:
- ReactiveX operators documentation: Do
-
doOnTerminate
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> doOnTerminate(@NonNull @NonNull Action onTerminate)
Returns anObservable
so that it invokes an action when the currentObservable
callsonComplete
oronError
.This differs from
doAfterTerminate
in that this happens before theonComplete
oronError
notification.- Scheduler:
doOnTerminate
does not operate by default on a particularScheduler
.
- Parameters:
onTerminate
- the action to invoke when the currentObservable
callsonComplete
oronError
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifonTerminate
isnull
- See Also:
- ReactiveX operators documentation: Do,
doAfterTerminate(Action)
-
elementAt
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> elementAt(long index)
Returns aMaybe
that emits the single item at a specified index in a sequence of emissions from the currentObservable
or completes if the currentObservable
signals fewer elements than index.- Scheduler:
elementAt
does not operate by default on a particularScheduler
.
- Parameters:
index
- the zero-based index of the item to retrieve- Returns:
- the new
Maybe
instance - Throws:
java.lang.IndexOutOfBoundsException
- ifindex
is negative- See Also:
- ReactiveX operators documentation: ElementAt
-
elementAt
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<T> elementAt(long index, @NonNull @NonNull T defaultItem)
Returns aSingle
that emits the item found at a specified index in a sequence of emissions from the currentObservable
, or a default item if that index is out of range.- Scheduler:
elementAt
does not operate by default on a particularScheduler
.
- Parameters:
index
- the zero-based index of the item to retrievedefaultItem
- the default item- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
java.lang.IndexOutOfBoundsException
- ifindex
is negative- See Also:
- ReactiveX operators documentation: ElementAt
-
elementAtOrError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<T> elementAtOrError(long index)
Returns aSingle
that emits the item found at a specified index in a sequence of emissions from the currentObservable
or signals aNoSuchElementException
if the currentObservable
signals fewer elements than index.- Scheduler:
elementAtOrError
does not operate by default on a particularScheduler
.
- Parameters:
index
- the zero-based index of the item to retrieve- Returns:
- the new
Single
instance - Throws:
java.lang.IndexOutOfBoundsException
- ifindex
is negative- See Also:
- ReactiveX operators documentation: ElementAt
-
filter
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> filter(@NonNull @NonNull Predicate<? super @NonNull T> predicate)
Filters items emitted by the currentObservable
by only emitting those that satisfy a specifiedPredicate
.- Scheduler:
filter
does not operate by default on a particularScheduler
.
- Parameters:
predicate
- a function that evaluates each item emitted by the currentObservable
, returningtrue
if it passes the filter- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
- See Also:
- ReactiveX operators documentation: Filter
-
firstElement
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> firstElement()
Returns aMaybe
that emits only the very first item emitted by the currentObservable
, or completes if the currentObservable
is empty.- Scheduler:
firstElement
does not operate by default on a particularScheduler
.
- Returns:
- the new
Maybe
instance - See Also:
- ReactiveX operators documentation: First
-
first
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<T> first(@NonNull @NonNull T defaultItem)
Returns aSingle
that emits only the very first item emitted by the currentObservable
, or a default item if the currentObservable
completes without emitting any items.- Scheduler:
first
does not operate by default on a particularScheduler
.
- Parameters:
defaultItem
- the default item to emit if the currentObservable
doesn't emit anything- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
- See Also:
- ReactiveX operators documentation: First
-
firstOrError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<T> firstOrError()
Returns aSingle
that emits only the very first item emitted by the currentObservable
or signals aNoSuchElementException
if the currentObservable
is empty.- Scheduler:
firstOrError
does not operate by default on a particularScheduler
.
- Returns:
- the new
Single
instance - See Also:
- ReactiveX operators documentation: First
-
flatMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper)
Returns anObservable
that emits items based on applying a function that you supply to each item emitted by the currentObservable
, where that function returns anObservableSource
, and then merging those returnedObservableSource
s and emitting the results of this merger.- Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the value type of the innerObservableSource
s and the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the currentObservable
, returns anObservableSource
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, boolean delayErrors)
Returns anObservable
that emits items based on applying a function that you supply to each item emitted by the currentObservable
, where that function returns anObservableSource
, and then merging those returnedObservableSource
s and emitting the results of this merger.- Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the value type of the innerObservableSource
s and the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the currentObservable
, returns anObservableSource
delayErrors
- iftrue
, exceptions from the currentObservable
and all innerObservableSource
s are delayed until all of them terminate iffalse
, the first one signaling an exception will terminate the whole sequence immediately- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, boolean delayErrors, int maxConcurrency)
Returns anObservable
that emits items based on applying a function that you supply to each item emitted by the currentObservable
, where that function returns anObservableSource
, and then merging those returnedObservableSource
s and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to theseObservableSource
s.- Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the value type of the innerObservableSource
s and the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the currentObservable
, returns anObservableSource
maxConcurrency
- the maximum number ofObservableSource
s that may be subscribed to concurrentlydelayErrors
- iftrue
, exceptions from the currentObservable
and all innerObservableSource
s are delayed until all of them terminate iffalse
, the first one signaling an exception will terminate the whole sequence immediately- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, boolean delayErrors, int maxConcurrency, int bufferSize)
Returns anObservable
that emits items based on applying a function that you supply to each item emitted by the currentObservable
, where that function returns anObservableSource
, and then merging those returnedObservableSource
s and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to theseObservableSource
s.- Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the value type of the innerObservableSource
s and the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the currentObservable
, returns anObservableSource
maxConcurrency
- the maximum number ofObservableSource
s that may be subscribed to concurrentlydelayErrors
- iftrue
, exceptions from the currentObservable
and all innerObservableSource
s are delayed until all of them terminate iffalse
, the first one signaling an exception will terminate the whole sequence immediatelybufferSize
- the number of elements expected from each innerObservableSource
to be buffered- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> onNextMapper, @NonNull @NonNull Function<? super java.lang.Throwable,? extends ObservableSource<? extends @NonNull R>> onErrorMapper, @NonNull @NonNull Supplier<? extends ObservableSource<? extends @NonNull R>> onCompleteSupplier)
Returns anObservable
that applies a function to each item emitted or notification raised by the currentObservable
and then flattens theObservableSource
s returned from these functions and emits the resulting items.- Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the result type- Parameters:
onNextMapper
- a function that returns anObservableSource
to merge for each item emitted by the currentObservable
onErrorMapper
- a function that returns anObservableSource
to merge for anonError
notification from the currentObservable
onCompleteSupplier
- a function that returns anObservableSource
to merge for anonComplete
notification from the currentObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifonNextMapper
oronErrorMapper
oronCompleteSupplier
isnull
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> onNextMapper, @NonNull @NonNull Function<java.lang.Throwable,? extends ObservableSource<? extends @NonNull R>> onErrorMapper, @NonNull @NonNull Supplier<? extends ObservableSource<? extends @NonNull R>> onCompleteSupplier, int maxConcurrency)
Returns anObservable
that applies a function to each item emitted or notification raised by the currentObservable
and then flattens theObservableSource
s returned from these functions and emits the resulting items, while limiting the maximum number of concurrent subscriptions to theseObservableSource
s.- Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the result type- Parameters:
onNextMapper
- a function that returns anObservableSource
to merge for each item emitted by the currentObservable
onErrorMapper
- a function that returns anObservableSource
to merge for anonError
notification from the currentObservable
onCompleteSupplier
- a function that returns anObservableSource
to merge for anonComplete
notification from the currentObservable
maxConcurrency
- the maximum number ofObservableSource
s that may be subscribed to concurrently- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifonNextMapper
oronErrorMapper
oronCompleteSupplier
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, int maxConcurrency)
Returns anObservable
that emits items based on applying a function that you supply to each item emitted by the currentObservable
, where that function returns anObservableSource
, and then merging those returnedObservableSource
s and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to theseObservableSource
s.- Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the value type of the innerObservableSource
s and the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the currentObservable
, returns anObservableSource
maxConcurrency
- the maximum number ofObservableSource
s that may be subscribed to concurrently- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull R> @NonNull Observable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull U>> mapper, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner)
Returns anObservable
that emits the results of a specified function to the pair of values emitted by the currentObservable
and the mapped innerObservableSource
.- Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted by the collectionObservableSource
R
- the type of items emitted by the resultingObservable
- Parameters:
mapper
- a function that returns anObservableSource
for each item emitted by the currentObservable
combiner
- a function that combines one item emitted by each of the source and collectionObservableSource
s and returns an item to be emitted by the resultingObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull R> @NonNull Observable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull U>> mapper, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner, boolean delayErrors)
Returns anObservable
that emits the results of a specified function to the pair of values emitted by the currentObservable
and the mapped innerObservableSource
.- Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted by the collectionObservableSource
R
- the type of items emitted by the resultingObservable
- Parameters:
mapper
- a function that returns anObservableSource
for each item emitted by the currentObservable
combiner
- a function that combines one item emitted by each of the source and collectionObservableSource
s and returns an item to be emitted by the resultingObservable
delayErrors
- iftrue
, exceptions from the currentObservable
and all innerObservableSource
s are delayed until all of them terminate iffalse
, the first one signaling an exception will terminate the whole sequence immediately- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull R> @NonNull Observable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull U>> mapper, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner, boolean delayErrors, int maxConcurrency)
Returns anObservable
that emits the results of a specified function to the pair of values emitted by the currentObservable
and the mapped innerObservableSource
, while limiting the maximum number of concurrent subscriptions to theseObservableSource
s.- Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted by the collectionObservableSource
R
- the type of items emitted by the resultingObservable
- Parameters:
mapper
- a function that returns anObservableSource
for each item emitted by the currentObservable
combiner
- a function that combines one item emitted by each of the source and collectionObservableSource
s and returns an item to be emitted by the resultingObservable
maxConcurrency
- the maximum number ofObservableSource
s that may be subscribed to concurrentlydelayErrors
- iftrue
, exceptions from the currentObservable
and all innerObservableSource
s are delayed until all of them terminate iffalse
, the first one signaling an exception will terminate the whole sequence immediately- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
orcombiner
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull R> @NonNull Observable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull U>> mapper, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner, boolean delayErrors, int maxConcurrency, int bufferSize)
Returns anObservable
that emits the results of a specified function to the pair of values emitted by the currentObservable
and the mapped innerObservableSource
, while limiting the maximum number of concurrent subscriptions to theseObservableSource
s.- Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted by the collectionObservableSource
R
- the type of items emitted by the resultingObservable
- Parameters:
mapper
- a function that returns anObservableSource
for each item emitted by the currentObservable
combiner
- a function that combines one item emitted by each of the source and collectionObservableSource
s and returns an item to be emitted by the resultingObservable
maxConcurrency
- the maximum number ofObservableSource
s that may be subscribed to concurrentlydelayErrors
- iftrue
, exceptions from the currentObservable
and all innerObservableSource
s are delayed until all of them terminate iffalse
, the first one signaling an exception will terminate the whole sequence immediatelybufferSize
- the number of elements expected from the innerObservableSource
to be buffered- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
orcombiner
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull R> @NonNull Observable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull U>> mapper, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner, int maxConcurrency)
Returns anObservable
that emits the results of a specified function to the pair of values emitted by the currentObservable
and the mapped innerObservableSource
, while limiting the maximum number of concurrent subscriptions to theseObservableSource
s.- Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted by the collectionObservableSource
R
- the type of items emitted by the resultingObservable
- Parameters:
mapper
- a function that returns anObservableSource
for each item emitted by the currentObservable
combiner
- a function that combines one item emitted by each of the source and collectionObservableSource
s and returns an item to be emitted by the resultingObservable
maxConcurrency
- the maximum number ofObservableSource
s that may be subscribed to concurrently- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
orcombiner
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMapCompletable
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Completable flatMapCompletable(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps each element of the currentObservable
intoCompletableSource
s, subscribes to them and waits until the upstream and allCompletableSource
s complete.- Scheduler:
flatMapCompletable
does not operate by default on a particularScheduler
.
- Parameters:
mapper
- the function that received each source value and transforms them intoCompletableSource
s.- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
-
flatMapCompletable
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Completable flatMapCompletable(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper, boolean delayErrors)
Maps each element of the currentObservable
intoCompletableSource
s, subscribes to them and waits until the upstream and allCompletableSource
s complete, optionally delaying all errors.- Scheduler:
flatMapCompletable
does not operate by default on a particularScheduler
.
- Parameters:
mapper
- the function that received each source value and transforms them intoCompletableSource
s.delayErrors
- iftrue
, errors from the upstream and innerCompletableSource
s are delayed until all of them terminate.- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
-
flatMapIterable
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U> @NonNull Observable<U> flatMapIterable(@NonNull @NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper)
MergesIterable
s generated by a mapperFunction
for each individual item emitted by the currentObservable
into a singleObservable
sequence.- Scheduler:
flatMapIterable
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the output type and the element type of theIterable
s- Parameters:
mapper
- a function that returns anIterable
sequence of values for when given an item emitted by the currentObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMapIterable
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull V> @NonNull Observable<V> flatMapIterable(@NonNull @NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull V> combiner)
MergesIterable
s generated by a mapperFunction
for each individual item emitted by the currentObservable
into a singleObservable
sequence where the resulting items will be the combination of the original item and each inner item of the respectiveIterable
as returned by theresultSelector
BiFunction
.- Scheduler:
flatMapIterable
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the element type of theIterable
sV
- the output type as determined by theresultSelector
function- Parameters:
mapper
- a function that returns anIterable
sequence of values for each item emitted by the currentObservable
combiner
- a function that returns an item based on the item emitted by the currentObservable
and the next item of theIterable
returned for that original item by themapper
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMapMaybe
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> flatMapMaybe(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps each element of the currentObservable
intoMaybeSource
s, subscribes to all of them and merges theironSuccess
values, in no particular order, into a singleObservable
sequence.- Scheduler:
flatMapMaybe
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the result value type- Parameters:
mapper
- the function that received each source value and transforms them intoMaybeSource
s.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
-
flatMapMaybe
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> flatMapMaybe(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper, boolean delayErrors)
Maps each element of the currentObservable
intoMaybeSource
s, subscribes to them and merges theironSuccess
values, in no particular order, into a singleObservable
sequence, optionally delaying all errors.- Scheduler:
flatMapMaybe
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the result value type- Parameters:
mapper
- the function that received each source value and transforms them intoMaybeSource
s.delayErrors
- iftrue
, errors from the upstream and innerMaybeSource
s are delayed until all of them terminate.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
-
flatMapSingle
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> flatMapSingle(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Maps each element of the currentObservable
intoSingleSource
s, subscribes to all of them and merges theironSuccess
values, in no particular order, into a singleObservable
sequence.- Scheduler:
flatMapSingle
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the result value type- Parameters:
mapper
- the function that received each source value and transforms them intoSingleSource
s.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
-
flatMapSingle
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> flatMapSingle(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper, boolean delayErrors)
Maps each element of the currentObservable
intoSingleSource
s, subscribes to them and merges theironSuccess
values, in no particular order, into a singleObservable
sequence, optionally delaying all errors.- Scheduler:
flatMapSingle
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the result value type- Parameters:
mapper
- the function that received each source value and transforms them intoSingleSource
s.delayErrors
- iftrue
, errors from the upstream and innerSingleSource
s are delayed until each of them terminates.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
-
forEach
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Disposable forEach(@NonNull @NonNull Consumer<? super @NonNull T> onNext)
Subscribes to theObservableSource
and calls aConsumer
for each item of the currentObservable
on its emission thread.Alias to
subscribe(Consumer)
- Scheduler:
forEach
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- theConsumer
to execute for each item.- Returns:
- a
Disposable
that allows disposing the sequence if the currentObservable
runs asynchronously - Throws:
java.lang.NullPointerException
- ifonNext
isnull
- See Also:
- ReactiveX operators documentation: Subscribe
-
forEachWhile
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Disposable forEachWhile(@NonNull @NonNull Predicate<? super @NonNull T> onNext)
Subscribes to theObservableSource
and calls aPredicate
for each item of the currentObservable
, on its emission thread, until the predicate returnsfalse
.If the
Observable
emits an error, it is wrapped into anOnErrorNotImplementedException
and routed to theRxJavaPlugins.onError(Throwable)
handler.- Scheduler:
forEachWhile
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- thePredicate
to execute for each item.- Returns:
- a
Disposable
that allows disposing the sequence if the currentObservable
runs asynchronously - Throws:
java.lang.NullPointerException
- ifonNext
isnull
- See Also:
- ReactiveX operators documentation: Subscribe
-
forEachWhile
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Disposable forEachWhile(@NonNull @NonNull Predicate<? super @NonNull T> onNext, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError)
Subscribes to theObservableSource
and calls aPredicate
for each item or aConsumer
with the error of the currentObservable
, on their original emission threads, until the predicate returnsfalse
.- Scheduler:
forEachWhile
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- thePredicate
to execute for each item.onError
- theConsumer
to execute when an error is emitted.- Returns:
- a
Disposable
that allows disposing the sequence if the currentObservable
runs asynchronously - Throws:
java.lang.NullPointerException
- ifonNext
oronError
isnull
- See Also:
- ReactiveX operators documentation: Subscribe
-
forEachWhile
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Disposable forEachWhile(@NonNull @NonNull Predicate<? super @NonNull T> onNext, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull @NonNull Action onComplete)
Subscribes to theObservableSource
and calls aPredicate
for each item, aConsumer
with the error or anAction
upon completion of the currentObservable
, on their original emission threads, until the predicate returnsfalse
.- Scheduler:
forEachWhile
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- thePredicate
to execute for each item.onError
- theConsumer
to execute when an error is emitted.onComplete
- theAction
to execute when completion is signaled.- Returns:
- a
Disposable
that allows disposing the sequence if the currentObservable
runs asynchronously - Throws:
java.lang.NullPointerException
- ifonNext
oronError
oronComplete
isnull
- See Also:
- ReactiveX operators documentation: Subscribe
-
groupBy
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull K> @NonNull Observable<GroupedObservable<K,T>> groupBy(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector)
Groups the items emitted by the currentObservable
according to a specified criterion, and emits these grouped items asGroupedObservable
s.Each emitted
GroupedObservable
allows only a singleObserver
to subscribe to it during its lifetime and if thisObserver
callsdispose()
before the source terminates, the next emission by the source having the same key will trigger a newGroupedObservable
emission.Note: A
GroupedObservable
will cache the items it is to emit until such time as it is subscribed to. For this reason, in order to avoid memory leaks, you should not simply ignore thoseGroupedObservable
s that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator likeignoreElements()
to them.Note also that ignoring groups or subscribing later (i.e., on another thread) will result in so-called group abandonment where a group will only contain one element and the group will be re-created over and over as new upstream items trigger a new group. The behavior is a trade-off between no-dataloss, upstream cancellation and excessive group creation.
- Scheduler:
groupBy
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type- Parameters:
keySelector
- a function that extracts the key for each item- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
isnull
- See Also:
- ReactiveX operators documentation: GroupBy
-
groupBy
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull K> @NonNull Observable<GroupedObservable<K,T>> groupBy(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, boolean delayError)
Groups the items emitted by the currentObservable
according to a specified criterion, and emits these grouped items asGroupedObservable
s.Each emitted
GroupedObservable
allows only a singleObserver
to subscribe to it during its lifetime and if thisObserver
callsdispose()
before the source terminates, the next emission by the source having the same key will trigger a newGroupedObservable
emission.Note: A
GroupedObservable
will cache the items it is to emit until such time as it is subscribed to. For this reason, in order to avoid memory leaks, you should not simply ignore thoseGroupedObservable
s that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator likeignoreElements()
to them.Note also that ignoring groups or subscribing later (i.e., on another thread) will result in so-called group abandonment where a group will only contain one element and the group will be re-created over and over as new upstream items trigger a new group. The behavior is a trade-off between no-dataloss, upstream cancellation and excessive group creation.
- Scheduler:
groupBy
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type- Parameters:
keySelector
- a function that extracts the key for each itemdelayError
- iftrue
, the exception from the currentObservable
is delayed in each group until that specific group emitted the normal values; iffalse
, the exception bypasses values in the groups and is reported immediately.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
isnull
- See Also:
- ReactiveX operators documentation: GroupBy
-
groupBy
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull K,@NonNull V> @NonNull Observable<GroupedObservable<K,V>> groupBy(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, Function<? super @NonNull T,? extends @NonNull V> valueSelector)
Groups the items emitted by the currentObservable
according to a specified criterion, and emits these grouped items asGroupedObservable
s.Each emitted
GroupedObservable
allows only a singleObserver
to subscribe to it during its lifetime and if thisObserver
callsdispose()
before the source terminates, the next emission by the source having the same key will trigger a newGroupedObservable
emission.Note: A
GroupedObservable
will cache the items it is to emit until such time as it is subscribed to. For this reason, in order to avoid memory leaks, you should not simply ignore thoseGroupedObservable
s that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator likeignoreElements()
to them.Note also that ignoring groups or subscribing later (i.e., on another thread) will result in so-called group abandonment where a group will only contain one element and the group will be re-created over and over as new upstream items trigger a new group. The behavior is a trade-off between no-dataloss, upstream cancellation and excessive group creation.
- Scheduler:
groupBy
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key typeV
- the element type- Parameters:
keySelector
- a function that extracts the key for each itemvalueSelector
- a function that extracts the return element for each item- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
orvalueSelector
isnull
- See Also:
- ReactiveX operators documentation: GroupBy
-
groupBy
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull K,@NonNull V> @NonNull Observable<GroupedObservable<K,V>> groupBy(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector, boolean delayError)
Groups the items emitted by the currentObservable
according to a specified criterion, and emits these grouped items asGroupedObservable
s.Each emitted
GroupedObservable
allows only a singleObserver
to subscribe to it during its lifetime and if thisObserver
callsdispose()
before the source terminates, the next emission by the source having the same key will trigger a newGroupedObservable
emission.Note: A
GroupedObservable
will cache the items it is to emit until such time as it is subscribed to. For this reason, in order to avoid memory leaks, you should not simply ignore thoseGroupedObservable
s that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator likeignoreElements()
to them.Note also that ignoring groups or subscribing later (i.e., on another thread) will result in so-called group abandonment where a group will only contain one element and the group will be re-created over and over as new upstream items trigger a new group. The behavior is a trade-off between no-dataloss, upstream cancellation and excessive group creation.
- Scheduler:
groupBy
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key typeV
- the element type- Parameters:
keySelector
- a function that extracts the key for each itemvalueSelector
- a function that extracts the return element for each itemdelayError
- iftrue
, the exception from the currentObservable
is delayed in each group until that specific group emitted the normal values; iffalse
, the exception bypasses values in the groups and is reported immediately.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
orvalueSelector
isnull
- See Also:
- ReactiveX operators documentation: GroupBy
-
groupBy
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull K,@NonNull V> @NonNull Observable<GroupedObservable<K,V>> groupBy(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector, boolean delayError, int bufferSize)
Groups the items emitted by the currentObservable
according to a specified criterion, and emits these grouped items asGroupedObservable
s.Each emitted
GroupedObservable
allows only a singleObserver
to subscribe to it during its lifetime and if thisObserver
callsdispose()
before the source terminates, the next emission by the source having the same key will trigger a newGroupedObservable
emission.Note: A
GroupedObservable
will cache the items it is to emit until such time as it is subscribed to. For this reason, in order to avoid memory leaks, you should not simply ignore thoseGroupedObservable
s that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator likeignoreElements()
to them.Note also that ignoring groups or subscribing later (i.e., on another thread) will result in so-called group abandonment where a group will only contain one element and the group will be re-created over and over as new upstream items trigger a new group. The behavior is a trade-off between no-dataloss, upstream cancellation and excessive group creation.
- Scheduler:
groupBy
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key typeV
- the element type- Parameters:
keySelector
- a function that extracts the key for each itemvalueSelector
- a function that extracts the return element for each itemdelayError
- iftrue
, the exception from the currentObservable
is delayed in each group until that specific group emitted the normal values; iffalse
, the exception bypasses values in the groups and is reported immediately.bufferSize
- the hint for how manyGroupedObservable
s and element in eachGroupedObservable
should be buffered- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
orvalueSelector
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: GroupBy
-
groupJoin
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull TRight,@NonNull TLeftEnd,@NonNull TRightEnd,@NonNull R> @NonNull Observable<R> groupJoin(@NonNull @NonNull ObservableSource<? extends @NonNull TRight> other, @NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull TLeftEnd>> leftEnd, @NonNull @NonNull Function<? super @NonNull TRight,? extends ObservableSource<@NonNull TRightEnd>> rightEnd, @NonNull @NonNull BiFunction<? super @NonNull T,? super Observable<@NonNull TRight>,? extends @NonNull R> resultSelector)
Returns anObservable
that correlates twoObservableSource
s when they overlap in time and groups the results.There are no guarantees in what order the items get combined when multiple items from one or both source
ObservableSource
s overlap.- Scheduler:
groupJoin
does not operate by default on a particularScheduler
.
- Type Parameters:
TRight
- the value type of the rightObservableSource
sourceTLeftEnd
- the element type of the left durationObservableSource
sTRightEnd
- the element type of the right durationObservableSource
sR
- the result type- Parameters:
other
- the otherObservableSource
to correlate items from the currentObservable
withleftEnd
- a function that returns anObservableSource
whose emissions indicate the duration of the values of the currentObservable
rightEnd
- a function that returns anObservableSource
whose emissions indicate the duration of the values of theright
ObservableSource
resultSelector
- a function that takes an item emitted by eachObservableSource
and returns the value to be emitted by the resultingObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
,leftEnd
,rightEnd
orresultSelector
isnull
- See Also:
- ReactiveX operators documentation: Join
-
hide
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> hide()
Hides the identity of the currentObservable
and itsDisposable
.Allows hiding extra features such as
Subject
'sObserver
methods or preventing certain identity-based optimizations (fusion).- Scheduler:
hide
does not operate by default on a particularScheduler
.
- Returns:
- the new
Observable
instance - Since:
- 2.0
-
ignoreElements
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Completable ignoreElements()
Ignores all items emitted by the currentObservable
and only callsonComplete
oronError
.- Scheduler:
ignoreElements
does not operate by default on a particularScheduler
.
- Returns:
- the new
Completable
instance - See Also:
- ReactiveX operators documentation: IgnoreElements
-
isEmpty
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<java.lang.Boolean> isEmpty()
Returns aSingle
that emitstrue
if the currentObservable
is empty, otherwisefalse
.In Rx.Net this is negated as the
any
Observer
but we renamed this in RxJava to better match Java naming idioms.- Scheduler:
isEmpty
does not operate by default on a particularScheduler
.
- Returns:
- the new
Single
instance - See Also:
- ReactiveX operators documentation: Contains
-
join
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull TRight,@NonNull TLeftEnd,@NonNull TRightEnd,@NonNull R> @NonNull Observable<R> join(@NonNull @NonNull ObservableSource<? extends @NonNull TRight> other, @NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull TLeftEnd>> leftEnd, @NonNull @NonNull Function<? super @NonNull TRight,? extends ObservableSource<@NonNull TRightEnd>> rightEnd, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull TRight,? extends @NonNull R> resultSelector)
Correlates the items emitted by twoObservableSource
s based on overlapping durations.There are no guarantees in what order the items get combined when multiple items from one or both source
ObservableSource
s overlap.- Scheduler:
join
does not operate by default on a particularScheduler
.
- Type Parameters:
TRight
- the value type of the rightObservableSource
sourceTLeftEnd
- the element type of the left durationObservableSource
sTRightEnd
- the element type of the right durationObservableSource
sR
- the result type- Parameters:
other
- the secondObservableSource
to join items fromleftEnd
- a function to select a duration for each item emitted by the currentObservable
, used to determine overlaprightEnd
- a function to select a duration for each item emitted by theright
ObservableSource
, used to determine overlapresultSelector
- a function that computes an item to be emitted by the resultingObservable
for any two overlapping items emitted by the twoObservableSource
s- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
,leftEnd
,rightEnd
orresultSelector
isnull
- See Also:
- ReactiveX operators documentation: Join
-
lastElement
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> lastElement()
Returns aMaybe
that emits the last item emitted by the currentObservable
or completes if the currentObservable
is empty.- Scheduler:
lastElement
does not operate by default on a particularScheduler
.
- Returns:
- the new
Maybe
instance - See Also:
- ReactiveX operators documentation: Last
-
last
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<T> last(@NonNull @NonNull T defaultItem)
Returns aSingle
that emits only the last item emitted by the currentObservable
, or a default item if the currentObservable
completes without emitting any items.- Scheduler:
last
does not operate by default on a particularScheduler
.
- Parameters:
defaultItem
- the default item to emit if the currentObservable
is empty- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
- See Also:
- ReactiveX operators documentation: Last
-
lastOrError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<T> lastOrError()
Returns aSingle
that emits only the last item emitted by the currentObservable
or signals aNoSuchElementException
if the currentObservable
is empty.- Scheduler:
lastOrError
does not operate by default on a particularScheduler
.
- Returns:
- the new
Single
instance - See Also:
- ReactiveX operators documentation: Last
-
lift
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> lift(@NonNull @NonNull ObservableOperator<? extends @NonNull R,? super @NonNull T> lifter)
This method requires advanced knowledge about building operators, please consider other standard composition methods first; Returns anObservable
which, when subscribed to, invokes theapply(Observer)
method of the providedObservableOperator
for each individual downstreamObserver
and allows the insertion of a custom operator by accessing the downstream'sObserver
during this subscription phase and providing a newObserver
, containing the custom operator's intended business logic, that will be used in the subscription process going further upstream.Generally, such a new
Observer
will wrap the downstream'sObserver
and forwards theonNext
,onError
andonComplete
events from the upstream directly or according to the emission pattern the custom operator's business logic requires. In addition, such operator can intercept the flow control calls ofdispose
andisDisposed
that would have traveled upstream and perform additional actions depending on the same business logic requirements.Example:
// Step 1: Create the consumer type that will be returned by the ObservableOperator.apply(): public final class CustomObserver<T> implements Observer<T>, Disposable { // The downstream's Observer that will receive the onXXX events final Observer<? super String> downstream; // The connection to the upstream source that will call this class' onXXX methods Disposable upstream; // The constructor takes the downstream subscriber and usually any other parameters public CustomObserver(Observer<? super String> downstream) { this.downstream = downstream; } // In the subscription phase, the upstream sends a Disposable to this class // and subsequently this class has to send a Disposable to the downstream. // Note that relaying the upstream's Disposable directly is not allowed in RxJava @Override public void onSubscribe(Disposable d) { if (upstream != null) { d.dispose(); } else { upstream = d; downstream.onSubscribe(this); } } // The upstream calls this with the next item and the implementation's // responsibility is to emit an item to the downstream based on the intended // business logic, or if it can't do so for the particular item, // request more from the upstream @Override public void onNext(T item) { String str = item.toString(); if (str.length() < 2) { downstream.onNext(str); } // Observable doesn't support backpressure, therefore, there is no // need or opportunity to call upstream.request(1) if an item // is not produced to the downstream } // Some operators may handle the upstream's error while others // could just forward it to the downstream. @Override public void onError(Throwable throwable) { downstream.onError(throwable); } // When the upstream completes, usually the downstream should complete as well. @Override public void onComplete() { downstream.onComplete(); } // Some operators may use their own resources which should be cleaned up if // the downstream disposes the flow before it completed. Operators without // resources can simply forward the dispose to the upstream. // In some cases, a disposed flag may be set by this method so that other parts // of this class may detect the dispose and stop sending events // to the downstream. @Override public void dispose() { upstream.dispose(); } // Some operators may simply forward the call to the upstream while others // can return the disposed flag set in dispose(). @Override public boolean isDisposed() { return upstream.isDisposed(); } } // Step 2: Create a class that implements the ObservableOperator interface and // returns the custom consumer type from above in its apply() method. // Such class may define additional parameters to be submitted to // the custom consumer type. final class CustomOperator<T> implements ObservableOperator<String, T> { @Override public Observer<T> apply(Observer<? super String> downstream) { return new CustomObserver<T>(downstream); } } // Step 3: Apply the custom operator via lift() in a flow by creating an instance of it // or reusing an existing one. Observable.range(5, 10) .lift(new CustomOperator<Integer>()) .test() .assertResult("5", "6", "7", "8", "9");
Creating custom operators can be complicated and it is recommended one consults the RxJava wiki: Writing operators page about the tools, requirements, rules, considerations and pitfalls of implementing them.
Note that implementing custom operators via this
lift()
method adds slightly more overhead by requiring an additional allocation and indirection per assembled flows. Instead, extending the abstractObservable
class and creating anObservableTransformer
with it is recommended.Note also that it is not possible to stop the subscription phase in
lift()
as theapply()
method requires a non-null
Observer
instance to be returned, which is then unconditionally subscribed to the currentObservable
. For example, if the operator decided there is no reason to subscribe to the upstream source because of some optimization possibility or a failure to prepare the operator, it still has to return anObserver
that should immediately dispose the upstream'sDisposable
in itsonSubscribe
method. Again, using anObservableTransformer
and extending theObservable
is a better option assubscribeActual(io.reactivex.rxjava3.core.Observer<? super T>)
can decide to not subscribe to its upstream after all.- Scheduler:
lift
does not operate by default on a particularScheduler
, however, theObservableOperator
may use aScheduler
to support its own asynchronous behavior.
- Type Parameters:
R
- the output value type- Parameters:
lifter
- theObservableOperator
that receives the downstream'sObserver
and should return anObserver
with custom behavior to be used as the consumer for the currentObservable
.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- iflifter
isnull
- See Also:
- RxJava wiki: Writing operators,
compose(ObservableTransformer)
-
map
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> map(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull R> mapper)
Returns anObservable
that applies a specified function to each item emitted by the currentObservable
and emits the results of these function applications.- Scheduler:
map
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the output type- Parameters:
mapper
- a function to apply to each item emitted by the currentObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- See Also:
- ReactiveX operators documentation: Map
-
materialize
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<Notification<T>> materialize()
Returns anObservable
that represents all of the emissions and notifications from the currentObservable
into emissions marked with their original types withinNotification
objects.- Scheduler:
materialize
does not operate by default on a particularScheduler
.
- Returns:
- the new
Observable
instance - See Also:
- ReactiveX operators documentation: Materialize,
dematerialize(Function)
-
mergeWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> mergeWith(@NonNull @NonNull ObservableSource<? extends @NonNull T> other)
Flattens the currentObservable
and anotherObservableSource
into a singleObservable
sequence, without any transformation.You can combine items emitted by multiple
ObservableSource
s so that they appear as a singleObservableSource
, by using themergeWith
method.- Scheduler:
mergeWith
does not operate by default on a particularScheduler
.
- Parameters:
other
- anObservableSource
to be merged- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- See Also:
- ReactiveX operators documentation: Merge
-
mergeWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> mergeWith(@NonNull @NonNull SingleSource<? extends @NonNull T> other)
Merges the sequence of items of the currentObservable
with the success value of the otherSingleSource
.The success value of the other
SingleSource
can get interleaved at any point of the currentObservable
sequence.- Scheduler:
mergeWith
does not operate by default on a particularScheduler
.
History: 2.1.10 - experimental
- Parameters:
other
- theSingleSource
whose success value to merge with- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 2.2
-
mergeWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> mergeWith(@NonNull @NonNull MaybeSource<? extends @NonNull T> other)
Merges the sequence of items of the currentObservable
with the success value of the otherMaybeSource
or waits both to complete normally if theMaybeSource
is empty.The success value of the other
MaybeSource
can get interleaved at any point of the currentObservable
sequence.- Scheduler:
mergeWith
does not operate by default on a particularScheduler
.
History: 2.1.10 - experimental
- Parameters:
other
- theMaybeSource
which provides a success value to merge with or completes- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 2.2
-
mergeWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> mergeWith(@NonNull @NonNull CompletableSource other)
Relays the items of the currentObservable
and completes only when the otherCompletableSource
completes as well.- Scheduler:
mergeWith
does not operate by default on a particularScheduler
.
History: 2.1.10 - experimental
- Parameters:
other
- theCompletableSource
to await for completion- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 2.2
-
observeOn
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> observeOn(@NonNull @NonNull Scheduler scheduler)
Returns anObservable
to perform the currentObservable
's emissions and notifications on a specifiedScheduler
, asynchronously with an unbounded buffer withFlowable.bufferSize()
"island size".Note that
onError
notifications will cut ahead ofonNext
notifications on the emission thread ifScheduler
is truly asynchronous. If strict event ordering is required, consider using theobserveOn(Scheduler, boolean)
overload.This operator keeps emitting as many signals as it can on the given
Scheduler
's worker thread, which may result in a longer than expected occupation of this thread. In other terms, it does not allow per-signal fairness in case the worker runs on a shared underlying thread. If such fairness and signal/work interleaving is preferred, use the delay operator with zero time instead.- Scheduler:
- You specify which
Scheduler
this operator will use.
"Island size" indicates how large chunks the unbounded buffer allocates to store the excess elements waiting to be consumed on the other side of the asynchronous boundary.
- Parameters:
scheduler
- theScheduler
to notifyObserver
s on- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifscheduler
isnull
- See Also:
- ReactiveX operators documentation: ObserveOn,
RxJava Threading Examples,
subscribeOn(io.reactivex.rxjava3.core.Scheduler)
,observeOn(Scheduler, boolean)
,observeOn(Scheduler, boolean, int)
,delay(long, TimeUnit, Scheduler)
-
observeOn
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> observeOn(@NonNull @NonNull Scheduler scheduler, boolean delayError)
Returns anObservable
to perform the currentObservable
's emissions and notifications on a specifiedScheduler
, asynchronously with an unbounded buffer withFlowable.bufferSize()
"island size" and optionally delaysonError
notifications.This operator keeps emitting as many signals as it can on the given
Scheduler
's worker thread, which may result in a longer than expected occupation of this thread. In other terms, it does not allow per-signal fairness in case the worker runs on a shared underlying thread. If such fairness and signal/work interleaving is preferred, use the delay operator with zero time instead.- Scheduler:
- You specify which
Scheduler
this operator will use.
"Island size" indicates how large chunks the unbounded buffer allocates to store the excess elements waiting to be consumed on the other side of the asynchronous boundary.
- Parameters:
scheduler
- theScheduler
to notifyObserver
s ondelayError
- indicates if theonError
notification may not cut ahead ofonNext
notification on the other side of the scheduling boundary. Iftrue
, a sequence ending inonError
will be replayed in the same order as was received from the currentObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifscheduler
isnull
- See Also:
- ReactiveX operators documentation: ObserveOn,
RxJava Threading Examples,
subscribeOn(io.reactivex.rxjava3.core.Scheduler)
,observeOn(Scheduler)
,observeOn(Scheduler, boolean, int)
,delay(long, TimeUnit, Scheduler, boolean)
-
observeOn
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> observeOn(@NonNull @NonNull Scheduler scheduler, boolean delayError, int bufferSize)
Returns anObservable
to perform the currentObservable
's emissions and notifications on a specifiedScheduler
, asynchronously with an unbounded buffer of configurable "island size" and optionally delaysonError
notifications.This operator keeps emitting as many signals as it can on the given
Scheduler
's worker thread, which may result in a longer than expected occupation of this thread. In other terms, it does not allow per-signal fairness in case the worker runs on a shared underlying thread. If such fairness and signal/work interleaving is preferred, use the delay operator with zero time instead.- Scheduler:
- You specify which
Scheduler
this operator will use.
"Island size" indicates how large chunks the unbounded buffer allocates to store the excess elements waiting to be consumed on the other side of the asynchronous boundary. Values below 16 are not recommended in performance sensitive scenarios.
- Parameters:
scheduler
- theScheduler
to notifyObserver
s ondelayError
- indicates if theonError
notification may not cut ahead ofonNext
notification on the other side of the scheduling boundary. Iftrue
a sequence ending inonError
will be replayed in the same order as was received from upstreambufferSize
- the size of the buffer.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifscheduler
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: ObserveOn,
RxJava Threading Examples,
subscribeOn(io.reactivex.rxjava3.core.Scheduler)
,observeOn(Scheduler)
,observeOn(Scheduler, boolean)
,delay(long, TimeUnit, Scheduler, boolean)
-
ofType
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U> @NonNull Observable<U> ofType(@NonNull @NonNull java.lang.Class<@NonNull U> clazz)
Filters the items emitted by the currentObservable
, only emitting those of the specified type.- Scheduler:
ofType
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the output type- Parameters:
clazz
- the class type to filter the items emitted by the currentObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifclazz
isnull
- See Also:
- ReactiveX operators documentation: Filter
-
onErrorComplete
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> onErrorComplete()
Returns anObservable
instance that if the currentObservable
emits an error, it will emit anonComplete
and swallow the throwable.- Scheduler:
onErrorComplete
does not operate by default on a particularScheduler
.
- Returns:
- the new
Observable
instance - Since:
- 3.0.0
-
onErrorComplete
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Observable<T> onErrorComplete(@NonNull @NonNull Predicate<? super java.lang.Throwable> predicate)
Returns anObservable
instance that if the currentObservable
emits an error and the predicate returnstrue
, it will emit anonComplete
and swallow the throwable.- Scheduler:
onErrorComplete
does not operate by default on a particularScheduler
.
- Parameters:
predicate
- the predicate to call when anThrowable
is emitted which should returntrue
if theThrowable
should be swallowed and replaced with anonComplete
.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
- Since:
- 3.0.0
-
onErrorResumeNext
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> onErrorResumeNext(@NonNull @NonNull Function<? super java.lang.Throwable,? extends ObservableSource<? extends @NonNull T>> fallbackSupplier)
Resumes the flow with anObservableSource
returned for the failureThrowable
of the currentObservable
by a function instead of signaling the error viaonError
.By default, when an
ObservableSource
encounters an error that prevents it from emitting the expected item to itsObserver
, theObservableSource
invokes itsObserver
'sonError
method, and then quits without invoking any more of itsObserver
's methods. TheonErrorResumeNext
method changes this behavior. If you pass a function that returns anObservableSource
(resumeFunction
) toonErrorResumeNext
, if the originalObservableSource
encounters an error, instead of invoking itsObserver
'sonError
method, it will instead relinquish control to theObservableSource
returned fromresumeFunction
, which will invoke theObserver
'sonNext
method if it is able to do so. In such a case, because noObservableSource
necessarily invokesonError
, theObserver
may never know that an error happened.You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
- Scheduler:
onErrorResumeNext
does not operate by default on a particularScheduler
.
- Parameters:
fallbackSupplier
- a function that returns anObservableSource
that will take over if the currentObservable
encounters an error- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- iffallbackSupplier
isnull
- See Also:
- ReactiveX operators documentation: Catch
-
onErrorResumeWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> onErrorResumeWith(@NonNull @NonNull ObservableSource<? extends @NonNull T> fallback)
Resumes the flow with the givenObservableSource
when the currentObservable
fails instead of signaling the error viaonError
.By default, when an
ObservableSource
encounters an error that prevents it from emitting the expected item to itsObserver
, theObservableSource
invokes itsObserver
'sonError
method, and then quits without invoking any more of itsObserver
's methods. TheonErrorResumeWith
method changes this behavior. If you pass anotherObservableSource
(next
) to anObservableSource
'sonErrorResumeWith
method, if the originalObservableSource
encounters an error, instead of invoking itsObserver
'sonError
method, it will instead relinquish control tonext
which will invoke theObserver
'sonNext
method if it is able to do so. In such a case, because noObservableSource
necessarily invokesonError
, theObserver
may never know that an error happened.You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
- Scheduler:
onErrorResumeWith
does not operate by default on a particularScheduler
.
- Parameters:
fallback
- the nextObservableSource
source that will take over if the currentObservable
encounters an error- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- iffallback
isnull
- See Also:
- ReactiveX operators documentation: Catch
-
onErrorReturn
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> onErrorReturn(@NonNull @NonNull Function<? super java.lang.Throwable,? extends @NonNull T> itemSupplier)
Ends the flow with a last item returned by a function for theThrowable
error signaled by the currentObservable
instead of signaling the error viaonError
.By default, when an
ObservableSource
encounters an error that prevents it from emitting the expected item to itsObserver
, theObservableSource
invokes itsObserver
'sonError
method, and then quits without invoking any more of itsObserver
's methods. TheonErrorReturn
method changes this behavior. If you pass a function (resumeFunction
) to anObservableSource
'sonErrorReturn
method, if the originalObservableSource
encounters an error, instead of invoking itsObserver
'sonError
method, it will instead emit the return value ofresumeFunction
.You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
- Scheduler:
onErrorReturn
does not operate by default on a particularScheduler
.
- Parameters:
itemSupplier
- a function that returns a single value that will be emitted along with a regularonComplete
in case the currentObservable
signals anonError
event- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitemSupplier
isnull
- See Also:
- ReactiveX operators documentation: Catch
-
onErrorReturnItem
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> onErrorReturnItem(@NonNull @NonNull T item)
Ends the flow with the given last item when the currentObservable
fails instead of signaling the error viaonError
.By default, when an
ObservableSource
encounters an error that prevents it from emitting the expected item to itsObserver
, theObservableSource
invokes itsObserver
'sonError
method, and then quits without invoking any more of itsObserver
's methods. TheonErrorReturn
method changes this behavior. If you pass a function (resumeFunction
) to anObservableSource
'sonErrorReturn
method, if the originalObservableSource
encounters an error, instead of invoking itsObserver
'sonError
method, it will instead emit the return value ofresumeFunction
.You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
- Scheduler:
onErrorReturnItem
does not operate by default on a particularScheduler
.
- Parameters:
item
- the value that is emitted along with a regularonComplete
in case the currentObservable
signals an exception- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitem
isnull
- See Also:
- ReactiveX operators documentation: Catch
-
onTerminateDetach
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> onTerminateDetach()
Nulls out references to the upstream producer and downstreamObserver
if the sequence is terminated or downstream callsdispose()
.- Scheduler:
onTerminateDetach
does not operate by default on a particularScheduler
.
- Returns:
- the new
Observable
instance the sequence is terminated or downstream callsdispose()
- Since:
- 2.0
-
publish
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull ConnectableObservable<T> publish()
Returns aConnectableObservable
, which is a variety ofObservableSource
that waits until itsconnect
method is called before it begins emitting items to thoseObserver
s that have subscribed to it.- Scheduler:
publish
does not operate by default on a particularScheduler
.
- Returns:
- the new
ConnectableObservable
instance - See Also:
- ReactiveX operators documentation: Publish
-
publish
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> publish(@NonNull @NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector)
Returns anObservable
that emits the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
sequence.- Scheduler:
publish
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the type of items emitted by the resultingObservable
- Parameters:
selector
- a function that can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence.Observer
s to the given source will receive all notifications of the source from the time of the subscription forward.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifselector
isnull
- See Also:
- ReactiveX operators documentation: Publish
-
reduce
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> reduce(@NonNull @NonNull BiFunction<@NonNull T,@NonNull T,@NonNull T> reducer)
Returns aMaybe
that applies a specified accumulator function to the first item emitted by the currentObservable
, then feeds the result of that function along with the second item emitted by the currentObservable
into the same function, and so on until all items have been emitted by the current and finiteObservable
, and emits the final result from the final call to your function as its sole item.This technique, which is called "reduce" here, is sometimes called "aggregate," "fold," "accumulate," "compress," or "inject" in other programming contexts. Groovy, for instance, has an
inject
method that does a similar operation on lists.Note that this operator requires the upstream to signal
onComplete
for the accumulator object to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
reduce
does not operate by default on a particularScheduler
.
- Parameters:
reducer
- an accumulator function to be invoked on each item emitted by the currentObservable
, whose result will be used in the next accumulator call- Returns:
- the new
Maybe
instance - Throws:
java.lang.NullPointerException
- ifreducer
isnull
- See Also:
- ReactiveX operators documentation: Reduce, Wikipedia: Fold (higher-order function)
-
reduce
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Single<R> reduce(@NonNull R seed, @NonNull @NonNull BiFunction<@NonNull R,? super @NonNull T,@NonNull R> reducer)
Returns aSingle
that applies a specified accumulator function to the first item emitted by the currentObservable
and a specified seed value, then feeds the result of that function along with the second item emitted by the currentObservable
into the same function, and so on until all items have been emitted by the current and finiteObservable
, emitting the final result from the final call to your function as its sole item.This technique, which is called "reduce" here, is sometimes called "aggregate," "fold," "accumulate," "compress," or "inject" in other programming contexts. Groovy, for instance, has an
inject
method that does a similar operation on lists.Note that the
seed
is shared among all subscribers to the resultingObservable
and may cause problems if it is mutable. To make sure each subscriber gets its own value, defer the application of this operator viadefer(Supplier)
:ObservableSource<T> source = ... Single.defer(() -> source.reduce(new ArrayList<>(), (list, item) -> list.add(item))); // alternatively, by using compose to stay fluent source.compose(o -> Observable.defer(() -> o.reduce(new ArrayList<>(), (list, item) -> list.add(item)).toObservable()) ).firstOrError(); // or, by using reduceWith instead of reduce source.reduceWith(() -> new ArrayList<>(), (list, item) -> list.add(item)));
Note that this operator requires the upstream to signal
onComplete
for the accumulator object to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
reduce
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the accumulator and output value type- Parameters:
seed
- the initial (seed) accumulator valuereducer
- an accumulator function to be invoked on each item emitted by the currentObservable
, the result of which will be used in the next accumulator call- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifseed
orreducer
isnull
- See Also:
- ReactiveX operators documentation: Reduce,
Wikipedia: Fold (higher-order function),
reduceWith(Supplier, BiFunction)
-
reduceWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Single<R> reduceWith(@NonNull @NonNull Supplier<@NonNull R> seedSupplier, @NonNull @NonNull BiFunction<@NonNull R,? super @NonNull T,@NonNull R> reducer)
Returns aSingle
that applies a specified accumulator function to the first item emitted by the currentObservable
and a seed value derived from calling a specifiedseedSupplier
, then feeds the result of that function along with the second item emitted by the currentObservable
into the same function, and so on until all items have been emitted by the current and finiteObservable
, emitting the final result from the final call to your function as its sole item.This technique, which is called "reduce" here, is sometimes called "aggregate," "fold," "accumulate," "compress," or "inject" in other programming contexts. Groovy, for instance, has an
inject
method that does a similar operation on lists.Note that this operator requires the upstream to signal
onComplete
for the accumulator object to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
reduceWith
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the accumulator and output value type- Parameters:
seedSupplier
- theSupplier
that provides the initial (seed) accumulator value for each individualObserver
reducer
- an accumulator function to be invoked on each item emitted by the currentObservable
, the result of which will be used in the next accumulator call- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifseedSupplier
orreducer
isnull
- See Also:
- ReactiveX operators documentation: Reduce, Wikipedia: Fold (higher-order function)
-
repeat
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> repeat()
Returns anObservable
that repeats the sequence of items emitted by the currentObservable
indefinitely.- Scheduler:
repeat
does not operate by default on a particularScheduler
.
- Returns:
- the new
Observable
instance - See Also:
- ReactiveX operators documentation: Repeat
-
repeat
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> repeat(long times)
Returns anObservable
that repeats the sequence of items emitted by the currentObservable
at mostcount
times.- Scheduler:
repeat
does not operate by default on a particularScheduler
.
- Parameters:
times
- the number of times the currentObservable
items are repeated, a count of 0 will yield an empty sequence- Returns:
- the new
Observable
instance - Throws:
java.lang.IllegalArgumentException
- iftimes
is negative- See Also:
- ReactiveX operators documentation: Repeat
-
repeatUntil
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> repeatUntil(@NonNull @NonNull BooleanSupplier stop)
Returns anObservable
that repeats the sequence of items emitted by the currentObservable
until the provided stop function returnstrue
.- Scheduler:
repeatUntil
does not operate by default on a particularScheduler
.
- Parameters:
stop
- a boolean supplier that is called when the currentObservable
completes; if it returnstrue
, the returnedObservable
completes; if it returnsfalse
, the currentObservable
is resubscribed.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifstop
isnull
- See Also:
- ReactiveX operators documentation: Repeat
-
repeatWhen
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> repeatWhen(@NonNull @NonNull Function<? super Observable<java.lang.Object>,? extends ObservableSource<?>> handler)
Returns anObservable
that emits the same values as the currentObservable
with the exception of anonComplete
. AnonComplete
notification from the source will result in the emission of avoid
item to theObservableSource
provided as an argument to thenotificationHandler
function. If thatObservableSource
callsonComplete
oronError
thenrepeatWhen
will callonComplete
oronError
on the child subscription. Otherwise, the currentObservable
will be resubscribed.- Scheduler:
repeatWhen
does not operate by default on a particularScheduler
.
- Parameters:
handler
- receives anObservableSource
of notifications with which a user can complete or error, aborting the repeat.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifhandler
isnull
- See Also:
- ReactiveX operators documentation: Repeat
-
replay
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull ConnectableObservable<T> replay()
Returns aConnectableObservable
that shares a single subscription to the currentObservable
that will replay all of its items and notifications to any futureObserver
. A connectableObservable
resembles an ordinaryObservable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.- Scheduler:
- This version of
replay
does not operate by default on a particularScheduler
.
- Returns:
- the new
ConnectableObservable
instance - See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> replay(@NonNull @NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector)
Returns anObservable
that emits items that are the results of invoking a specified selector on the items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
.- Scheduler:
- This version of
replay
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the type of items emitted by the resultingObservable
- Parameters:
selector
- the selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifselector
isnull
- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> replay(@NonNull @NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector, int bufferSize)
Returns anObservable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
, replayingbufferSize
notifications.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions.- Scheduler:
- This version of
replay
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the type of items emitted by the resultingObservable
- Parameters:
selector
- the selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentObservable
bufferSize
- the buffer size that limits the number of items the connectableObservable
can replay- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifselector
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Replay,
replay(Function, int, boolean)
-
replay
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> replay(@NonNull @NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector, int bufferSize, boolean eagerTruncate)
Returns anObservable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
, replayingbufferSize
notifications.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions.- Scheduler:
- This version of
replay
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the type of items emitted by the resultingObservable
- Parameters:
selector
- the selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentObservable
bufferSize
- the buffer size that limits the number of items the connectableObservable
can replayeagerTruncate
- iftrue
, whenever the internal buffer is truncated to the given bufferSize, the oldest item will be guaranteed dereferenced, thus avoiding unexpected retention- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifselector
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final <@NonNull R> @NonNull Observable<R> replay(@NonNull @NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector, int bufferSize, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
, replaying no more thanbufferSize
items that were emitted within a specified time window.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions.- Scheduler:
- This version of
replay
operates by default on thecomputation
Scheduler
.
- Type Parameters:
R
- the type of items emitted by the resultingObservable
- Parameters:
selector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentObservable
bufferSize
- the buffer size that limits the number of items the connectableObservable
can replaytime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifselector
orunit
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final <@NonNull R> @NonNull Observable<R> replay(@NonNull @NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector, int bufferSize, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
, replaying no more thanbufferSize
items that were emitted within a specified time window.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Type Parameters:
R
- the type of items emitted by the resultingObservable
- Parameters:
selector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentObservable
bufferSize
- the buffer size that limits the number of items the connectableObservable
can replaytime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
scheduler
- theScheduler
that is the time source for the window- Returns:
- the new
Observable
instance - Throws:
java.lang.IllegalArgumentException
- ifbufferSize
is non-positivejava.lang.NullPointerException
- ifselector
,unit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Replay,
replay(Function, int, long, TimeUnit, Scheduler, boolean)
-
replay
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final <@NonNull R> @NonNull Observable<R> replay(@NonNull @NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector, int bufferSize, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean eagerTruncate)
Returns anObservable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
, replaying no more thanbufferSize
items that were emitted within a specified time window.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Type Parameters:
R
- the type of items emitted by the resultingObservable
- Parameters:
selector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentObservable
bufferSize
- the buffer size that limits the number of items the connectableObservable
can replaytime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
scheduler
- theScheduler
that is the time source for the windoweagerTruncate
- iftrue
, whenever the internal buffer is truncated to the given bufferSize/age, the oldest item will be guaranteed dereferenced, thus avoiding unexpected retention- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifselector
,unit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final <@NonNull R> @NonNull Observable<R> replay(@NonNull @NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
, replaying all items that were emitted within a specified time window.- Scheduler:
- This version of
replay
operates by default on thecomputation
Scheduler
.
- Type Parameters:
R
- the type of items emitted by the resultingObservable
- Parameters:
selector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentObservable
time
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifselector
orunit
isnull
- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final <@NonNull R> @NonNull Observable<R> replay(@NonNull @NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
, replaying all items that were emitted within a specified time window.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Type Parameters:
R
- the type of items emitted by the resultingObservable
- Parameters:
selector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentObservable
time
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
scheduler
- the scheduler that is the time source for the window- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifselector
,unit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Replay,
replay(Function, long, TimeUnit, Scheduler, boolean)
-
replay
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final <@NonNull R> @NonNull Observable<R> replay(@NonNull @NonNull Function<? super Observable<@NonNull T>,? extends ObservableSource<@NonNull R>> selector, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean eagerTruncate)
Returns anObservable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableObservable
that shares a single subscription to the currentObservable
, replaying all items that were emitted within a specified time window.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Type Parameters:
R
- the type of items emitted by the resultingObservable
- Parameters:
selector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentObservable
time
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
scheduler
- the scheduler that is the time source for the windoweagerTruncate
- iftrue
, whenever the internal buffer is truncated to the given age, the oldest item will be guaranteed dereferenced, thus avoiding unexpected retention- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifselector
,unit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull ConnectableObservable<T> replay(int bufferSize)
Returns aConnectableObservable
that shares a single subscription to the currentObservable
that replays at mostbufferSize
items emitted by the currentObservable
. A connectableObservable
resembles an ordinaryObservable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions. To ensure no beyond-bufferSize items are referenced, use thereplay(int, boolean)
overload witheagerTruncate = true
.- Scheduler:
- This version of
replay
does not operate by default on a particularScheduler
.
- Parameters:
bufferSize
- the buffer size that limits the number of items that can be replayed- Returns:
- the new
ConnectableObservable
instance - Throws:
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Replay,
replay(int, boolean)
-
replay
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull ConnectableObservable<T> replay(int bufferSize, boolean eagerTruncate)
Returns aConnectableObservable
that shares a single subscription to the currentObservable
that replays at mostbufferSize
items emitted by the currentObservable
. A connectableObservable
resembles an ordinaryObservable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions. To ensure no beyond-bufferSize items are referenced, seteagerTruncate = true
.- Scheduler:
- This version of
replay
does not operate by default on a particularScheduler
.
- Parameters:
bufferSize
- the buffer size that limits the number of items that can be replayedeagerTruncate
- iftrue
, whenever the internal buffer is truncated to the given bufferSize/age, the oldest item will be guaranteed dereferenced, thus avoiding unexpected retention- Returns:
- the new
ConnectableObservable
instance - Throws:
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull ConnectableObservable<T> replay(int bufferSize, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aConnectableObservable
that shares a single subscription to the currentObservable
and replays at mostbufferSize
items that were emitted during a specified time window. A connectableObservable
resembles an ordinaryObservable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions. To ensure no out-of-date or beyond-bufferSize items are referenced, use thereplay(int, long, TimeUnit, Scheduler, boolean)
overload witheagerTruncate = true
.- Scheduler:
- This version of
replay
operates by default on thecomputation
Scheduler
.
- Parameters:
bufferSize
- the buffer size that limits the number of items that can be replayedtime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
- Returns:
- the new
ConnectableObservable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Replay,
replay(int, long, TimeUnit, Scheduler, boolean)
-
replay
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull ConnectableObservable<T> replay(int bufferSize, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aConnectableObservable
that shares a single subscription to the currentObservable
and that replays a maximum ofbufferSize
items that are emitted within a specified time window. A connectableObservable
resembles an ordinaryObservable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions. To ensure no out-of-date or beyond-bufferSize items are referenced, use thereplay(int, long, TimeUnit, Scheduler, boolean)
overload witheagerTruncate = true
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
bufferSize
- the buffer size that limits the number of items that can be replayedtime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
scheduler
- the scheduler that is used as a time source for the window- Returns:
- the new
ConnectableObservable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Replay,
replay(int, long, TimeUnit, Scheduler, boolean)
-
replay
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull ConnectableObservable<T> replay(int bufferSize, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean eagerTruncate)
Returns aConnectableObservable
that shares a single subscription to the currentObservable
and that replays a maximum ofbufferSize
items that are emitted within a specified time window. A connectableObservable
resembles an ordinaryObservable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions. To ensure no out-of-date or beyond-bufferSize items are referenced, seteagerTruncate = true
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
bufferSize
- the buffer size that limits the number of items that can be replayedtime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
scheduler
- the scheduler that is used as a time source for the windoweagerTruncate
- iftrue
, whenever the internal buffer is truncated to the given bufferSize/age, the oldest item will be guaranteed dereferenced, thus avoiding unexpected retention- Returns:
- the new
ConnectableObservable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull ConnectableObservable<T> replay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aConnectableObservable
that shares a single subscription to the currentObservable
and replays all items emitted by the currentObservable
within a specified time window. A connectableObservable
resembles an ordinaryObservable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.- Scheduler:
- This version of
replay
operates by default on thecomputation
Scheduler
.
- Parameters:
time
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
- Returns:
- the new
ConnectableObservable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull ConnectableObservable<T> replay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aConnectableObservable
that shares a single subscription to the currentObservable
and replays all items emitted by the currentObservable
within a specified time window. A connectableObservable
resembles an ordinaryObservable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.Note that the internal buffer may retain strong references to the oldest item. To ensure no out-of-date items are referenced, use the
replay(long, TimeUnit, Scheduler, boolean)
overload witheagerTruncate = true
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
scheduler
- theScheduler
that is the time source for the window- Returns:
- the new
ConnectableObservable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Replay,
replay(long, TimeUnit, Scheduler, boolean)
-
replay
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull ConnectableObservable<T> replay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean eagerTruncate)
Returns aConnectableObservable
that shares a single subscription to the currentObservable
and replays all items emitted by the currentObservable
within a specified time window. A connectableObservable
resembles an ordinaryObservable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.Note that the internal buffer may retain strong references to the oldest item. To ensure no out-of-date items are referenced, set
eagerTruncate = true
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
scheduler
- theScheduler
that is the time source for the windoweagerTruncate
- iftrue
, whenever the internal buffer is truncated to the given bufferSize/age, the oldest item will be guaranteed dereferenced, thus avoiding unexpected retention- Returns:
- the new
ConnectableObservable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Replay
-
retry
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> retry()
Returns anObservable
that mirrors the currentObservable
, resubscribing to it if it callsonError
(infinite retry count).If the current
Observable
callsObserver.onError(java.lang.Throwable)
, this method will resubscribe to the currentObservable
rather than propagating theonError
call.Any and all items emitted by the current
Observable
will be emitted by the resultingObservable
, even those emitted during failed subscriptions. For example, if the currentObservable
fails at first but emits[1, 2]
then succeeds the second time and emits[1, 2, 3, 4, 5]
then the complete sequence of emissions and notifications would be[1, 2, 1, 2, 3, 4, 5, onComplete]
.- Scheduler:
retry
does not operate by default on a particularScheduler
.
- Returns:
- the new
Observable
instance - See Also:
- ReactiveX operators documentation: Retry
-
retry
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> retry(@NonNull @NonNull BiPredicate<? super java.lang.Integer,? super java.lang.Throwable> predicate)
Returns anObservable
that mirrors the currentObservable
, resubscribing to it if it callsonError
and the predicate returnstrue
for that specific exception and retry count.- Scheduler:
retry
does not operate by default on a particularScheduler
.
- Parameters:
predicate
- the predicate that determines if a resubscription may happen in case of a specific exception and retry count- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
- See Also:
retry()
, ReactiveX operators documentation: Retry
-
retry
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> retry(long times)
Returns anObservable
that mirrors the currentObservable
, resubscribing to it if it callsonError
up to a specified number of retries.If the current
Observable
callsObserver.onError(java.lang.Throwable)
, this method will resubscribe to the currentObservable
for a maximum ofcount
resubscriptions rather than propagating theonError
call.Any and all items emitted by the current
Observable
will be emitted by the resultingObservable
, even those emitted during failed subscriptions. For example, if the currentObservable
fails at first but emits[1, 2]
then succeeds the second time and emits[1, 2, 3, 4, 5]
then the complete sequence of emissions and notifications would be[1, 2, 1, 2, 3, 4, 5, onComplete]
.- Scheduler:
retry
does not operate by default on a particularScheduler
.
- Parameters:
times
- the number of times to resubscribe if the currentObservable
fails- Returns:
- the new
Observable
instance - Throws:
java.lang.IllegalArgumentException
- iftimes
is negative- See Also:
- ReactiveX operators documentation: Retry
-
retry
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> retry(long times, @NonNull @NonNull Predicate<? super java.lang.Throwable> predicate)
Retries at most times or until the predicate returnsfalse
, whichever happens first.- Scheduler:
retry
does not operate by default on a particularScheduler
.
- Parameters:
times
- the number of times to resubscribe if the currentObservable
failspredicate
- the predicate called with the failureThrowable
and should returntrue
to trigger a retry.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
java.lang.IllegalArgumentException
- iftimes
is negative
-
retry
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> retry(@NonNull @NonNull Predicate<? super java.lang.Throwable> predicate)
Retries the currentObservable
if the predicate returnstrue
.- Scheduler:
retry
does not operate by default on a particularScheduler
.
- Parameters:
predicate
- the predicate that receives the failureThrowable
and should returntrue
to trigger a retry.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
-
retryUntil
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> retryUntil(@NonNull @NonNull BooleanSupplier stop)
Retries until the given stop function returnstrue
.- Scheduler:
retryUntil
does not operate by default on a particularScheduler
.
- Parameters:
stop
- the function that should returntrue
to stop retrying- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifstop
isnull
-
retryWhen
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> retryWhen(@NonNull @NonNull Function<? super Observable<java.lang.Throwable>,? extends ObservableSource<?>> handler)
Returns anObservable
that emits the same values as the currentObservable
with the exception of anonError
. AnonError
notification from the source will result in the emission of aThrowable
item to theObservable
provided as an argument to thenotificationHandler
function. If thatObservable
callsonComplete
oronError
thenretry
will callonComplete
oronError
on the child subscription. Otherwise, the currentObservable
will be resubscribed.Example: This retries 3 times, each time incrementing the number of seconds it waits.
Output is:Observable.create((ObservableEmitter<? super String> s) -> { System.out.println("subscribing"); s.onError(new RuntimeException("always fails")); }).retryWhen(attempts -> { return attempts.zipWith(Observable.range(1, 3), (n, i) -> i).flatMap(i -> { System.out.println("delay retry by " + i + " second(s)"); return Observable.timer(i, TimeUnit.SECONDS); }); }).blockingForEach(System.out::println);
subscribing delay retry by 1 second(s) subscribing delay retry by 2 second(s) subscribing delay retry by 3 second(s) subscribing
Note that the inner
ObservableSource
returned by the handler function should signal eitheronNext
,onError
oronComplete
in response to the receivedThrowable
to indicate the operator should retry or terminate. If the upstream to the operator is asynchronous, signalingonNext
followed byonComplete
immediately may result in the sequence to be completed immediately. Similarly, if this innerObservableSource
signalsonError
oronComplete
while the upstream is active, the sequence is terminated with the same signal immediately.The following example demonstrates how to retry an asynchronous source with a delay:
Observable.timer(1, TimeUnit.SECONDS) .doOnSubscribe(s -> System.out.println("subscribing")) .map(v -> { throw new RuntimeException(); }) .retryWhen(errors -> { AtomicInteger counter = new AtomicInteger(); return errors .takeWhile(e -> counter.getAndIncrement() != 3) .flatMap(e -> { System.out.println("delay retry by " + counter.get() + " second(s)"); return Observable.timer(counter.get(), TimeUnit.SECONDS); }); }) .blockingSubscribe(System.out::println, System.out::println);
- Scheduler:
retryWhen
does not operate by default on a particularScheduler
.
- Parameters:
handler
- receives anObservable
of notifications with which a user can complete or error, aborting the retry- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifhandler
isnull
- See Also:
- ReactiveX operators documentation: Retry
-
safeSubscribe
@SchedulerSupport("none") public final void safeSubscribe(@NonNull @NonNull Observer<? super @NonNull T> observer)
Subscribes to the currentObservable
and wraps the givenObserver
into aSafeObserver
(if not already aSafeObserver
) that deals with exceptions thrown by a misbehavingObserver
(that doesn't follow the Reactive Streams specification).- Scheduler:
safeSubscribe
does not operate by default on a particularScheduler
.
- Parameters:
observer
- the incomingObserver
instance- Throws:
java.lang.NullPointerException
- ifobserver
isnull
-
sample
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<T> sample(long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits the most recently emitted item (if any) emitted by the currentObservable
within periodic time intervals.- Scheduler:
sample
operates by default on thecomputation
Scheduler
.
- Parameters:
period
- the sampling rateunit
- theTimeUnit
in whichperiod
is defined- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Sample,
throttleLast(long, TimeUnit)
-
sample
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<T> sample(long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit, boolean emitLast)
Returns anObservable
that emits the most recently emitted item (if any) emitted by the currentObservable
within periodic time intervals and optionally emit the very last upstream item when the upstream completes.- Scheduler:
sample
operates by default on thecomputation
Scheduler
.
History: 2.0.5 - experimental
- Parameters:
period
- the sampling rateunit
- theTimeUnit
in whichperiod
is definedemitLast
- iftrue
and the upstream completes while there is still an unsampled item available, that item is emitted to downstream before completion iffalse
, an unsampled last item is ignored.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- Since:
- 2.1
- See Also:
- ReactiveX operators documentation: Sample,
throttleLast(long, TimeUnit)
-
sample
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> sample(long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits the most recently emitted item (if any) emitted by the currentObservable
within periodic time intervals, where the intervals are defined on a particularScheduler
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
period
- the sampling rateunit
- theTimeUnit
in whichperiod
is definedscheduler
- theScheduler
to use when sampling- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Sample,
throttleLast(long, TimeUnit, Scheduler)
-
sample
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> sample(long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean emitLast)
Returns anObservable
that emits the most recently emitted item (if any) emitted by the currentObservable
within periodic time intervals, where the intervals are defined on a particularScheduler
and optionally emit the very last upstream item when the upstream completes.- Scheduler:
- You specify which
Scheduler
this operator will use.
History: 2.0.5 - experimental
- Parameters:
period
- the sampling rateunit
- theTimeUnit
in whichperiod
is definedscheduler
- theScheduler
to use when samplingemitLast
- iftrue
and the upstream completes while there is still an unsampled item available, that item is emitted to downstream before completion iffalse
, an unsampled last item is ignored.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- Since:
- 2.1
- See Also:
- ReactiveX operators documentation: Sample,
throttleLast(long, TimeUnit, Scheduler)
-
sample
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> sample(long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean emitLast, @NonNull @NonNull Consumer<? super @NonNull T> onDropped)
Returns anObservable
that emits the most recently emitted item (if any) emitted by the currentObservable
within periodic time intervals, where the intervals are defined on a particularScheduler
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
period
- the sampling rateunit
- theTimeUnit
in whichperiod
is definedscheduler
- theScheduler
to use when samplingemitLast
- iftrue
and the upstream completes while there is still an unsampled item available, that item is emitted to downstream before completion iffalse
, an unsampled last item is ignored.onDropped
- called with the current entry when it has been replaced by a new one- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
oronDropped
isnull
- Since:
- 3.1.6 - Experimental
- See Also:
- ReactiveX operators documentation: Sample,
throttleLast(long, TimeUnit, Scheduler)
-
sample
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U> @NonNull Observable<T> sample(@NonNull @NonNull ObservableSource<@NonNull U> sampler)
Returns anObservable
that, when the specifiedsampler
ObservableSource
emits an item or completes, emits the most recently emitted item (if any) emitted by the currentObservable
since the previous emission from thesampler
ObservableSource
.- Scheduler:
- This version of
sample
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the element type of the samplerObservableSource
- Parameters:
sampler
- theObservableSource
to use for sampling the currentObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsampler
isnull
- See Also:
- ReactiveX operators documentation: Sample
-
sample
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U> @NonNull Observable<T> sample(@NonNull @NonNull ObservableSource<@NonNull U> sampler, boolean emitLast)
Returns anObservable
that, when the specifiedsampler
ObservableSource
emits an item or completes, emits the most recently emitted item (if any) emitted by the currentObservable
since the previous emission from thesampler
ObservableSource
and optionally emit the very last upstream item when the upstream or otherObservableSource
complete.- Scheduler:
- This version of
sample
does not operate by default on a particularScheduler
.
History: 2.0.5 - experimental
- Type Parameters:
U
- the element type of the samplerObservableSource
- Parameters:
sampler
- theObservableSource
to use for sampling the currentObservable
emitLast
- iftrue
and the upstream completes while there is still an unsampled item available, that item is emitted to downstream before completion iffalse
, an unsampled last item is ignored.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsampler
isnull
- Since:
- 2.1
- See Also:
- ReactiveX operators documentation: Sample
-
scan
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> scan(@NonNull @NonNull BiFunction<@NonNull T,@NonNull T,@NonNull T> accumulator)
Returns anObservable
that emits the first value emitted by the currentObservable
, then emits one value for each subsequent value emitted by the currentObservable
. Each emission after the first is the result of applying the specified accumulator function to the previous emission and the corresponding value from the currentObservable
.This sort of function is sometimes called an accumulator.
- Scheduler:
scan
does not operate by default on a particularScheduler
.
- Parameters:
accumulator
- an accumulator function to be invoked on each item emitted by the currentObservable
, whose result will be emitted toObserver
s viaonNext
and used in the next accumulator call- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifaccumulator
isnull
- See Also:
- ReactiveX operators documentation: Scan
-
scan
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> scan(@NonNull @NonNull R initialValue, @NonNull @NonNull BiFunction<@NonNull R,? super @NonNull T,@NonNull R> accumulator)
Returns anObservable
that emits the provided initial (seed) value, then emits one value for each value emitted by the currentObservable
. Each emission after the first is the result of applying the specified accumulator function to the previous emission and the corresponding value from the currentObservable
.This sort of function is sometimes called an accumulator.
Note that the
Observable
that results from this method will emitinitialValue
as its first emitted item.Note that the
initialValue
is shared among all subscribers to the resultingObservable
and may cause problems if it is mutable. To make sure each subscriber gets its own value, defer the application of this operator viadefer(Supplier)
:ObservableSource<T> source = ... Observable.defer(() -> source.scan(new ArrayList<>(), (list, item) -> list.add(item))); // alternatively, by using compose to stay fluent source.compose(o -> Observable.defer(() -> o.scan(new ArrayList<>(), (list, item) -> list.add(item))) );
- Scheduler:
scan
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the initial, accumulator and result type- Parameters:
initialValue
- the initial (seed) accumulator itemaccumulator
- an accumulator function to be invoked on each item emitted by the currentObservable
, whose result will be emitted toObserver
s viaonNext
and used in the next accumulator call- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifinitialValue
oraccumulator
isnull
- See Also:
- ReactiveX operators documentation: Scan
-
scanWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> scanWith(@NonNull @NonNull Supplier<@NonNull R> seedSupplier, @NonNull @NonNull BiFunction<@NonNull R,? super @NonNull T,@NonNull R> accumulator)
Returns anObservable
that emits the provided initial (seed) value, then emits one value for each value emitted by the currentObservable
. Each emission after the first is the result of applying the specified accumulator function to the previous emission and the corresponding value from the currentObservable
.This sort of function is sometimes called an accumulator.
Note that the
Observable
that results from this method will emit the value returned by theseedSupplier
as its first item.- Scheduler:
scanWith
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the initial, accumulator and result type- Parameters:
seedSupplier
- aSupplier
that returns the initial (seed) accumulator item for each individualObserver
accumulator
- an accumulator function to be invoked on each item emitted by the currentObservable
, whose result will be emitted toObserver
s viaonNext
and used in the next accumulator call- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifseedSupplier
oraccumulator
isnull
- See Also:
- ReactiveX operators documentation: Scan
-
serialize
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> serialize()
Forces the currentObservable
's emissions and notifications to be serialized and for it to obey theObservableSource
contract in other ways.It is possible for an
Observable
to invoke itsObserver
s' methods asynchronously, perhaps from different threads. This could make such anObservable
poorly-behaved, in that it might try to invokeonComplete
oronError
before one of itsonNext
invocations, or it might callonNext
from two different threads concurrently. You can force such anObservable
to be well-behaved and sequential by applying theserialize
method to it.- Scheduler:
serialize
does not operate by default on a particularScheduler
.
- Returns:
- the new
Observable
instance - See Also:
- ReactiveX operators documentation: Serialize
-
share
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> share()
Returns a newObservable
that multicasts (and shares a single subscription to) the currentObservable
. As long as there is at least oneObserver
, the currentObservable
will stay subscribed and keep emitting signals. When all observers have disposed, the operator will dispose the subscription to the currentObservable
.This is an alias for
publish()
.refCount()
.- Scheduler:
share
does not operate by default on a particularScheduler
.
- Returns:
- the new
Observable
instance - See Also:
- ReactiveX operators documentation: RefCount
-
singleElement
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> singleElement()
Returns aMaybe
that completes if the currentObservable
is empty or emits the single item emitted by the currentObservable
, or signals anIllegalArgumentException
if the currentObservable
emits more than one item.- Scheduler:
singleElement
does not operate by default on a particularScheduler
.
- Returns:
- the new
Maybe
instance - See Also:
- ReactiveX operators documentation: First
-
single
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<T> single(@NonNull @NonNull T defaultItem)
Returns aSingle
that emits the single item emitted by the currentObservable
, if the currentObservable
emits only a single item, or a default item if the currentObservable
emits no items. If the currentObservable
emits more than one item, anIllegalArgumentException
is signaled instead.- Scheduler:
single
does not operate by default on a particularScheduler
.
- Parameters:
defaultItem
- a default value to emit if the currentObservable
emits no item- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
- See Also:
- ReactiveX operators documentation: First
-
singleOrError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<T> singleOrError()
Returns aSingle
that emits the single item emitted by the currentObservable
if it emits only a single item, otherwise if the currentObservable
completes without emitting any items or emits more than one item aNoSuchElementException
orIllegalArgumentException
will be signaled respectively.- Scheduler:
singleOrError
does not operate by default on a particularScheduler
.
- Returns:
- the new
Single
instance - See Also:
- ReactiveX operators documentation: First
-
skip
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> skip(long count)
Returns anObservable
that skips the firstcount
items emitted by the currentObservable
and emits the remainder.- Scheduler:
- This version of
skip
does not operate by default on a particularScheduler
.
- Parameters:
count
- the number of items to skip- Returns:
- the new
Observable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
is negative- See Also:
- ReactiveX operators documentation: Skip
-
skip
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<T> skip(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that skips values emitted by the currentObservable
before a specified time window elapses.- Scheduler:
skip
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.
- Parameters:
time
- the length of the time window to skipunit
- the time unit oftime
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Skip
-
skip
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> skip(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that skips values emitted by the currentObservable
before a specified time window on a specifiedScheduler
elapses.- Scheduler:
- You specify which
Scheduler
this operator will use for the timed skipping
- Parameters:
time
- the length of the time window to skipunit
- the time unit oftime
scheduler
- theScheduler
on which the timed wait happens- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Skip
-
skipLast
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> skipLast(int count)
Returns anObservable
that drops a specified number of items from the end of the sequence emitted by the currentObservable
.This
Observer
accumulates a queue long enough to store the firstcount
items. As more items are received, items are taken from the front of the queue and emitted by the returnedObservable
. This causes such items to be delayed.- Scheduler:
- This version of
skipLast
does not operate by default on a particularScheduler
.
- Parameters:
count
- number of items to drop from the end of the source sequence- Returns:
- the new
Observable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
is negative- See Also:
- ReactiveX operators documentation: SkipLast
-
skipLast
@CheckReturnValue @SchedulerSupport("io.reactivex:trampoline") @NonNull public final @NonNull Observable<T> skipLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that drops items emitted by the currentObservable
during a specified time window before the source completes.Note: this action will cache the latest items arriving in the specified time window.
- Scheduler:
skipLast
does not operate on any particular scheduler but uses the current time from thetrampoline
Scheduler
.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: SkipLast
-
skipLast
@CheckReturnValue @SchedulerSupport("io.reactivex:trampoline") @NonNull public final @NonNull Observable<T> skipLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, boolean delayError)
Returns anObservable
that drops items emitted by the currentObservable
during a specified time window before the source completes.Note: this action will cache the latest items arriving in the specified time window.
- Scheduler:
skipLast
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
delayError
- iftrue
, an exception signaled by the currentObservable
is delayed until the regular elements are consumed by the downstream; iffalse
, an exception is immediately signaled and all regular elements dropped- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: SkipLast
-
skipLast
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> skipLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that drops items emitted by the currentObservable
during a specified time window (defined on a specified scheduler) before the source completes.Note: this action will cache the latest items arriving in the specified time window.
- Scheduler:
- You specify which
Scheduler
this operator will use for tracking the current time
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
scheduler
- the scheduler used as the time source- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: SkipLast
-
skipLast
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> skipLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean delayError)
Returns anObservable
that drops items emitted by the currentObservable
during a specified time window (defined on a specified scheduler) before the source completes.Note: this action will cache the latest items arriving in the specified time window.
- Scheduler:
- You specify which
Scheduler
this operator will use to track the current time
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
scheduler
- the scheduler used as the time sourcedelayError
- iftrue
, an exception signaled by the currentObservable
is delayed until the regular elements are consumed by the downstream; iffalse
, an exception is immediately signaled and all regular elements dropped- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: SkipLast
-
skipLast
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> skipLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean delayError, int bufferSize)
Returns anObservable
that drops items emitted by the currentObservable
during a specified time window (defined on a specified scheduler) before the source completes.Note: this action will cache the latest items arriving in the specified time window.
- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
scheduler
- the scheduler used as the time sourcedelayError
- iftrue
, an exception signaled by the currentObservable
is delayed until the regular elements are consumed by the downstream; iffalse
, an exception is immediately signaled and all regular elements droppedbufferSize
- the hint about how many elements to expect to be skipped- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: SkipLast
-
skipUntil
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U> @NonNull Observable<T> skipUntil(@NonNull @NonNull ObservableSource<@NonNull U> other)
Returns anObservable
that skips items emitted by the currentObservable
until a secondObservableSource
emits an item.- Scheduler:
skipUntil
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the element type of the otherObservableSource
- Parameters:
other
- the secondObservableSource
that has to emit an item before the currentObservable
's elements begin to be mirrored by the resultingObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- See Also:
- ReactiveX operators documentation: SkipUntil
-
skipWhile
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> skipWhile(@NonNull @NonNull Predicate<? super @NonNull T> predicate)
Returns anObservable
that skips all items emitted by the currentObservable
as long as a specified condition holdstrue
, but emits all further source items as soon as the condition becomesfalse
.- Scheduler:
skipWhile
does not operate by default on a particularScheduler
.
- Parameters:
predicate
- a function to test each item emitted from the currentObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
- See Also:
- ReactiveX operators documentation: SkipWhile
-
sorted
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> sorted()
Returns anObservable
that emits the events emitted by the currentObservable
, in a sorted order. Each item emitted by the currentObservable
must implementComparable
with respect to all other items in the sequence.If any item emitted by the current
Observable
does not implementComparable
with respect to all other items emitted by the currentObservable
, no items will be emitted and the sequence is terminated with aClassCastException
.Note that calling
sorted
with long, non-terminating or infinite sources might causeOutOfMemoryError
- Scheduler:
sorted
does not operate by default on a particularScheduler
.
- Returns:
- the new
Observable
instance
-
sorted
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> sorted(@NonNull @NonNull java.util.Comparator<? super @NonNull T> comparator)
Returns anObservable
that emits the events emitted by the currentObservable
, in a sorted order based on a specified comparison function.Note that calling
sorted
with long, non-terminating or infinite sources might causeOutOfMemoryError
- Scheduler:
sorted
does not operate by default on a particularScheduler
.
- Parameters:
comparator
- a function that compares two items emitted by the currentObservable
and returns anint
that indicates their sort order- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifcomparator
isnull
-
startWithIterable
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> startWithIterable(@NonNull @NonNull java.lang.Iterable<? extends @NonNull T> items)
Returns anObservable
that emits the items in a specifiedIterable
before it begins to emit items emitted by the currentObservable
.- Scheduler:
startWithIterable
does not operate by default on a particularScheduler
.
- Parameters:
items
- anIterable
that contains the items you want the resultingObservable
to emit first- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitems
isnull
- Since:
- 3.0.0
- See Also:
- ReactiveX operators documentation: StartWith,
startWithItem(Object)
,startWithArray(Object...)
-
startWith
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Observable<T> startWith(@NonNull @NonNull CompletableSource other)
Returns anObservable
which first runs the otherCompletableSource
then the currentObservable
if the other completed normally.- Scheduler:
startWith
does not operate by default on a particularScheduler
.
- Parameters:
other
- the otherCompletableSource
to run first- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 3.0.0
-
startWith
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Observable<T> startWith(@NonNull @NonNull SingleSource<@NonNull T> other)
Returns anObservable
which first runs the otherSingleSource
then the currentObservable
if the other succeeded normally.- Scheduler:
startWith
does not operate by default on a particularScheduler
.
- Parameters:
other
- the otherSingleSource
to run first- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 3.0.0
-
startWith
@CheckReturnValue @NonNull @SchedulerSupport("none") public final @NonNull Observable<T> startWith(@NonNull @NonNull MaybeSource<@NonNull T> other)
Returns anObservable
which first runs the otherMaybeSource
then the currentObservable
if the other succeeded or completed normally.- Scheduler:
startWith
does not operate by default on a particularScheduler
.
- Parameters:
other
- the otherMaybeSource
to run first- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 3.0.0
-
startWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> startWith(@NonNull @NonNull ObservableSource<? extends @NonNull T> other)
Returns anObservable
that emits the items in a specifiedObservableSource
before it begins to emit items emitted by the currentObservable
.- Scheduler:
startWith
does not operate by default on a particularScheduler
.
- Parameters:
other
- anObservableSource
that contains the items you want the modifiedObservableSource
to emit first- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- See Also:
- ReactiveX operators documentation: StartWith
-
startWithItem
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> startWithItem(@NonNull @NonNull T item)
Returns anObservable
that emits a specified item before it begins to emit items emitted by the currentObservable
.- Scheduler:
startWithItem
does not operate by default on a particularScheduler
.
- Parameters:
item
- the item to emit first- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitem
isnull
- Since:
- 3.0.0
- See Also:
- ReactiveX operators documentation: StartWith,
startWithArray(Object...)
,startWithIterable(Iterable)
-
startWithArray
@CheckReturnValue @SchedulerSupport("none") @SafeVarargs @NonNull public final @NonNull Observable<T> startWithArray(@NonNull @NonNull T... items)
Returns anObservable
that emits the specified items before it begins to emit items emitted by the currentObservable
.- Scheduler:
startWithArray
does not operate by default on a particularScheduler
.
- Parameters:
items
- the array of values to emit first- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitems
isnull
- See Also:
- ReactiveX operators documentation: StartWith,
startWithItem(Object)
,startWithIterable(Iterable)
-
subscribe
@SchedulerSupport("none") @NonNull public final @NonNull Disposable subscribe()
Subscribes to the currentObservable
and ignoresonNext
andonComplete
emissions.If the
Observable
emits an error, it is wrapped into anOnErrorNotImplementedException
and routed to theRxJavaPlugins.onError(Throwable)
handler.- Scheduler:
subscribe
does not operate by default on a particularScheduler
.
- Returns:
- the new
Disposable
instance that can be used to dispose the subscription at any time - See Also:
- ReactiveX operators documentation: Subscribe,
subscribe(Consumer, Consumer, Action, DisposableContainer)
-
subscribe
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Disposable subscribe(@NonNull @NonNull Consumer<? super @NonNull T> onNext)
Subscribes to the currentObservable
and provides a callback to handle the items it emits.If the
Observable
emits an error, it is wrapped into anOnErrorNotImplementedException
and routed to theRxJavaPlugins.onError(Throwable)
handler.- Scheduler:
subscribe
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- theConsumer<T>
you have designed to accept emissions from the currentObservable
- Returns:
- the new
Disposable
instance that can be used to dispose the subscription at any time - Throws:
java.lang.NullPointerException
- ifonNext
isnull
- See Also:
- ReactiveX operators documentation: Subscribe,
subscribe(Consumer, Consumer, Action, DisposableContainer)
-
subscribe
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Disposable subscribe(@NonNull @NonNull Consumer<? super @NonNull T> onNext, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError)
Subscribes to the currentObservable
and provides callbacks to handle the items it emits and any error notification it signals.- Scheduler:
subscribe
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- theConsumer<T>
you have designed to accept emissions from the currentObservable
onError
- theConsumer<Throwable>
you have designed to accept any error notification from the currentObservable
- Returns:
- the new
Disposable
instance that can be used to dispose the subscription at any time - Throws:
java.lang.NullPointerException
- ifonNext
oronError
isnull
- See Also:
- ReactiveX operators documentation: Subscribe,
subscribe(Consumer, Consumer, Action, DisposableContainer)
-
subscribe
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Disposable subscribe(@NonNull @NonNull Consumer<? super @NonNull T> onNext, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull @NonNull Action onComplete)
Subscribes to the currentObservable
and provides callbacks to handle the items it emits and any error or completion notification it signals.- Scheduler:
subscribe
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- theConsumer<T>
you have designed to accept emissions from the currentObservable
onError
- theConsumer<Throwable>
you have designed to accept any error notification from the currentObservable
onComplete
- theAction
you have designed to accept a completion notification from the currentObservable
- Returns:
- the new
Disposable
instance that can be used to dispose the subscription at any time - Throws:
java.lang.NullPointerException
- ifonNext
,onError
oronComplete
isnull
- See Also:
- ReactiveX operators documentation: Subscribe,
subscribe(Consumer, Consumer, Action, DisposableContainer)
-
subscribe
@SchedulerSupport("none") @NonNull public final @NonNull Disposable subscribe(@NonNull @NonNull Consumer<? super @NonNull T> onNext, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull @NonNull Action onComplete, @NonNull @NonNull DisposableContainer container)
Wraps the given onXXX callbacks into aDisposable
Observer
, adds it to the givenDisposableContainer
and ensures, that if the upstream terminates or this particularDisposable
is disposed, theObserver
is removed from the given container.The
Observer
will be removed after the callback for the terminal event has been invoked.- Scheduler:
subscribe
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- the callback for upstream itemsonError
- the callback for an upstream error if anyonComplete
- the callback for the upstream completion if anycontainer
- theDisposableContainer
(such asCompositeDisposable
) to add and remove the createdDisposable
Observer
- Returns:
- the
Disposable
that allows disposing the particular subscription. - Throws:
java.lang.NullPointerException
- ifonNext
,onError
,onComplete
orcontainer
isnull
- Since:
- 3.1.0
-
subscribe
@SchedulerSupport("none") public final void subscribe(@NonNull @NonNull Observer<? super @NonNull T> observer)
Description copied from interface:ObservableSource
Subscribes the givenObserver
to thisObservableSource
instance.- Specified by:
subscribe
in interfaceObservableSource<T>
- Parameters:
observer
- theObserver
, notnull
-
subscribeActual
protected abstract void subscribeActual(@NonNull @NonNull Observer<? super @NonNull T> observer)
Operator implementations (both source and intermediate) should implement this method that performs the necessary business logic and handles the incomingObserver
s.There is no need to call any of the plugin hooks on the current
Observable
instance or theObserver
; all hooks and basic safeguards have been applied bysubscribe(Observer)
before this method gets called.- Parameters:
observer
- the incomingObserver
, nevernull
-
subscribeWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull E extends Observer<? super @NonNull T>> E subscribeWith(@NonNull E observer)
Subscribes a givenObserver
(subclass) to the currentObservable
and returns the givenObserver
instance as is.Usage example:
Observable<Integer> source = Observable.range(1, 10); CompositeDisposable composite = new CompositeDisposable(); DisposableObserver<Integer> ds = new DisposableObserver<>() { // ... }; composite.add(source.subscribeWith(ds));
- Scheduler:
subscribeWith
does not operate by default on a particularScheduler
.
- Type Parameters:
E
- the type of theObserver
to use and return- Parameters:
observer
- theObserver
(subclass) to use and return, notnull
- Returns:
- the input
observer
- Throws:
java.lang.NullPointerException
- ifobserver
isnull
- Since:
- 2.0
-
subscribeOn
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> subscribeOn(@NonNull @NonNull Scheduler scheduler)
Asynchronously subscribesObserver
s to the currentObservable
on the specifiedScheduler
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
scheduler
- theScheduler
to perform subscription actions on- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifscheduler
isnull
- See Also:
- ReactiveX operators documentation: SubscribeOn,
RxJava Threading Examples,
observeOn(io.reactivex.rxjava3.core.Scheduler)
-
switchIfEmpty
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> switchIfEmpty(@NonNull @NonNull ObservableSource<? extends @NonNull T> other)
Returns anObservable
that emits the items emitted by the currentObservable
or the items of an alternateObservableSource
if the currentObservable
is empty.- Scheduler:
switchIfEmpty
does not operate by default on a particularScheduler
.
- Parameters:
other
- the alternateObservableSource
to subscribe to if the source does not emit any items- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 1.1.0
-
switchMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> switchMap(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper)
Returns a newObservable
by applying a function that you supply to each item emitted by the currentObservable
that returns anObservableSource
, and then emitting the items emitted by the most recently emitted of theseObservableSource
s.The resulting
Observable
completes if both the currentObservable
and the last innerObservableSource
, if any, complete. If the currentObservable
signals anonError
, the innerObservableSource
is disposed and the error delivered in-sequence.- Scheduler:
switchMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the element type of the innerObservableSource
s and the output- Parameters:
mapper
- a function that, when applied to an item emitted by the currentObservable
, returns anObservableSource
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- See Also:
- ReactiveX operators documentation: FlatMap,
switchMapDelayError(Function)
-
switchMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> switchMap(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, int bufferSize)
Returns a newObservable
by applying a function that you supply to each item emitted by the currentObservable
that returns anObservableSource
, and then emitting the items emitted by the most recently emitted of theseObservableSource
s.The resulting
Observable
completes if both the currentObservable
and the last innerObservableSource
, if any, complete. If the currentObservable
signals anonError
, the innerObservableSource
is disposed and the error delivered in-sequence.- Scheduler:
switchMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the element type of the innerObservableSource
s and the output- Parameters:
mapper
- a function that, when applied to an item emitted by the currentObservable
, returns anObservableSource
bufferSize
- the number of elements expected from the current active innerObservableSource
to be buffered- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: FlatMap,
switchMapDelayError(Function, int)
-
switchMapCompletable
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Completable switchMapCompletable(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps the items of the currentObservable
intoCompletableSource
s, subscribes to the newer one while disposing the subscription to the previousCompletableSource
, thus keeping at most one activeCompletableSource
running.Since a
CompletableSource
doesn't produce any items, the resulting reactive type of this operator is aCompletable
that can only indicate successful completion or a failure in any of the innerCompletableSource
s or the failure of the currentObservable
.- Scheduler:
switchMapCompletable
does not operate by default on a particularScheduler
.- Error handling:
- If either the current
Observable
or the activeCompletableSource
signals anonError
, the resultingCompletable
is terminated immediately with thatThrowable
. Use theswitchMapCompletableDelayError(Function)
to delay such inner failures until every innerCompletableSource
s and the mainObservable
terminates in some fashion. If they fail concurrently, the operator may combine theThrowable
s into aCompositeException
and signal it to the downstream instead. If any inactivated (switched out)CompletableSource
signals anonError
late, theThrowable
s will be signaled to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors.
History: 2.1.11 - experimental
- Parameters:
mapper
- the function called with each upstream item and should return aCompletableSource
to be subscribed to and awaited for (non blockingly) for its terminal event- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
switchMapCompletableDelayError(Function)
-
switchMapCompletableDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Completable switchMapCompletableDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps the upstream values intoCompletableSource
s, subscribes to the newer one while disposing the subscription to the previousCompletableSource
, thus keeping at most one activeCompletableSource
running and delaying any main or inner errors until all of them terminate.Since a
CompletableSource
doesn't produce any items, the resulting reactive type of this operator is aCompletable
that can only indicate successful completion or a failure in any of the innerCompletableSource
s or the failure of the currentObservable
.- Scheduler:
switchMapCompletableDelayError
does not operate by default on a particularScheduler
.- Error handling:
- The errors of the current
Observable
and all theCompletableSource
s, who had the chance to run to their completion, are delayed until all of them terminate in some fashion. At this point, if there was only one failure, the respectiveThrowable
is emitted to the downstream. It there were more than one failures, the operator combines allThrowable
s into aCompositeException
and signals that to the downstream. If any inactivated (switched out)CompletableSource
signals anonError
late, theThrowable
s will be signaled to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors.
History: 2.1.11 - experimental
- Parameters:
mapper
- the function called with each upstream item and should return aCompletableSource
to be subscribed to and awaited for (non blockingly) for its terminal event- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
switchMapCompletable(Function)
-
switchMapMaybe
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> switchMapMaybe(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps the items of the currentObservable
intoMaybeSource
s and switches (subscribes) to the newer ones while disposing the older ones (and ignoring their signals) and emits the latest success value of the current one if available while failing immediately if the currentObservable
or any of the active innerMaybeSource
s fail.- Scheduler:
switchMapMaybe
does not operate by default on a particularScheduler
.- Error handling:
- This operator terminates with an
onError
if the currentObservable
or any of the innerMaybeSource
s fail while they are active. When this happens concurrently, their individualThrowable
errors may get combined and emitted as a singleCompositeException
. Otherwise, a late (i.e., inactive or switched out)onError
from the currentObservable
or from any of the innerMaybeSource
s will be forwarded to the global error handler viaRxJavaPlugins.onError(Throwable)
asUndeliverableException
History: 2.1.11 - experimental
- Type Parameters:
R
- the output value type- Parameters:
mapper
- the function called with the current upstream event and should return aMaybeSource
to replace the current active inner source and get subscribed to.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
switchMapMaybeDelayError(Function)
-
switchMapMaybeDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> switchMapMaybeDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps the upstream items intoMaybeSource
s and switches (subscribes) to the newer ones while disposing the older ones (and ignoring their signals) and emits the latest success value of the current one if available, delaying errors from the currentObservable
or the innerMaybeSource
s until all terminate.- Scheduler:
switchMapMaybeDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the output value type- Parameters:
mapper
- the function called with the current upstream event and should return aMaybeSource
to replace the current active inner source and get subscribed to.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
switchMapMaybe(Function)
-
switchMapSingle
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> switchMapSingle(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Returns a newObservable
by applying a function that you supply to each item emitted by the currentObservable
that returns aSingleSource
, and then emitting the item emitted by the most recently emitted of theseSingleSource
s.The resulting
Observable
completes if both the currentObservable
and the last innerSingleSource
, if any, complete. If the currentObservable
signals anonError
, the innerSingleSource
is disposed and the error delivered in-sequence.- Scheduler:
switchMapSingle
does not operate by default on a particularScheduler
.
History: 2.0.8 - experimental
- Type Parameters:
R
- the element type of the innerSingleSource
s and the output- Parameters:
mapper
- a function that, when applied to an item emitted by the currentObservable
, returns aSingleSource
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
- ReactiveX operators documentation: FlatMap,
switchMapSingleDelayError(Function)
-
switchMapSingleDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> switchMapSingleDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Returns a newObservable
by applying a function that you supply to each item emitted by the currentObservable
that returns aSingleSource
, and then emitting the item emitted by the most recently emitted of theseSingleSource
s and delays any error until allSingleSource
s terminate.The resulting
Observable
completes if both the currentObservable
and the last innerSingleSource
, if any, complete. If the currentObservable
signals anonError
, the termination of the last innerSingleSource
will emit that error as is or wrapped into aCompositeException
along with the other possible errors the former innerSingleSource
s signaled.- Scheduler:
switchMapSingleDelayError
does not operate by default on a particularScheduler
.
History: 2.0.8 - experimental
- Type Parameters:
R
- the element type of the innerSingleSource
s and the output- Parameters:
mapper
- a function that, when applied to an item emitted by the currentObservable
, returns aSingleSource
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
- ReactiveX operators documentation: FlatMap,
switchMapSingle(Function)
-
switchMapDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> switchMapDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper)
Returns a newObservable
by applying a function that you supply to each item emitted by the currentObservable
that returns anObservableSource
, and then emitting the items emitted by the most recently emitted of theseObservableSource
s and delays any error until allObservableSource
s terminate.The resulting
Observable
completes if both the currentObservable
and the last innerObservableSource
, if any, complete. If the currentObservable
signals anonError
, the termination of the last innerObservableSource
will emit that error as is or wrapped into aCompositeException
along with the other possible errors the former innerObservableSource
s signaled.- Scheduler:
switchMapDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the element type of the innerObservableSource
s and the output- Parameters:
mapper
- a function that, when applied to an item emitted by the currentObservable
, returns anObservableSource
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap,
switchMap(Function)
-
switchMapDelayError
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> switchMapDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<? extends @NonNull R>> mapper, int bufferSize)
Returns a newObservable
by applying a function that you supply to each item emitted by the currentObservable
that returns anObservableSource
, and then emitting the items emitted by the most recently emitted of theseObservableSource
s and delays any error until allObservableSource
s terminate.The resulting
Observable
completes if both the currentObservable
and the last innerObservableSource
, if any, complete. If the currentObservable
signals anonError
, the termination of the last innerObservableSource
will emit that error as is or wrapped into aCompositeException
along with the other possible errors the former innerObservableSource
s signaled.- Scheduler:
switchMapDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the element type of the innerObservableSource
s and the output- Parameters:
mapper
- a function that, when applied to an item emitted by the currentObservable
, returns anObservableSource
bufferSize
- the number of elements expected from the current active innerObservableSource
to be buffered- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap,
switchMap(Function, int)
-
take
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> take(long count)
Returns anObservable
that emits only the firstcount
items emitted by the currentObservable
. If the source emits fewer thancount
items then all of its items are emitted.This method returns an
Observable
that will invoke a subscribingObserver
'sonNext
function a maximum ofcount
times before invokingonComplete
.Taking
0
items from the currentObservable
will still subscribe to it, allowing the subscription-time side-effects to happen there, but will be immediately disposed and the downstream completed without any item emission.- Scheduler:
- This version of
take
does not operate by default on a particularScheduler
.
- Parameters:
count
- the maximum number of items to emit- Returns:
- the new
Observable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
is negative- See Also:
- ReactiveX operators documentation: Take
-
take
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> take(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits those items emitted by the currentObservable
before a specified time runs out.If time runs out before the
Observable
completes normally, theonComplete
event will be signaled on the defaultcomputation
Scheduler
.- Scheduler:
- This version of
take
operates by default on thecomputation
Scheduler
.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Take
-
take
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> take(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits those items emitted by the currentObservable
before a specified time (on a specifiedScheduler
) runs out.If time runs out before the
Observable
completes normally, theonComplete
event will be signaled on the providedScheduler
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
scheduler
- theScheduler
used for time source- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Take
-
takeLast
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> takeLast(int count)
Returns anObservable
that emits at most the lastcount
items emitted by the currentObservable
. If the source emits fewer thancount
items then all of its items are emitted.- Scheduler:
- This version of
takeLast
does not operate by default on a particularScheduler
.
- Parameters:
count
- the maximum number of items to emit from the end of the sequence of items emitted by the currentObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
is negative- See Also:
- ReactiveX operators documentation: TakeLast
-
takeLast
@CheckReturnValue @SchedulerSupport("io.reactivex:trampoline") @NonNull public final @NonNull Observable<T> takeLast(long count, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits at most a specified number of items from the currentObservable
that were emitted in a specified window of time before the currentObservable
completed.- Scheduler:
takeLast
does not operate on any particular scheduler but uses the current time from thetrampoline
Scheduler
.
- Parameters:
count
- the maximum number of items to emittime
- the length of the time windowunit
- the time unit oftime
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
java.lang.IllegalArgumentException
- ifcount
is negative- See Also:
- ReactiveX operators documentation: TakeLast
-
takeLast
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> takeLast(long count, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits at most a specified number of items from the currentObservable
that were emitted in a specified window of time before the currentObservable
completed, where the timing information is provided by a givenScheduler
.- Scheduler:
- You specify which
Scheduler
this operator will use for tracking the current time
- Parameters:
count
- the maximum number of items to emittime
- the length of the time windowunit
- the time unit oftime
scheduler
- theScheduler
that provides the timestamps for the observed items- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifcount
is negative- See Also:
- ReactiveX operators documentation: TakeLast
-
takeLast
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> takeLast(long count, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean delayError, int bufferSize)
Returns anObservable
that emits at most a specified number of items from the currentObservable
that were emitted in a specified window of time before the currentObservable
completed, where the timing information is provided by a givenScheduler
.- Scheduler:
- You specify which
Scheduler
this operator will use for tracking the current time
- Parameters:
count
- the maximum number of items to emittime
- the length of the time windowunit
- the time unit oftime
scheduler
- theScheduler
that provides the timestamps for the observed itemsdelayError
- iftrue
, an exception signaled by the currentObservable
is delayed until the regular elements are consumed by the downstream; iffalse
, an exception is immediately signaled and all regular elements droppedbufferSize
- the hint about how many elements to expect to be last- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifcount
is negative orbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: TakeLast
-
takeLast
@CheckReturnValue @SchedulerSupport("io.reactivex:trampoline") @NonNull public final @NonNull Observable<T> takeLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits the items from the currentObservable
that were emitted in a specified window of time before the currentObservable
completed.- Scheduler:
takeLast
does not operate on any particular scheduler but uses the current time from thetrampoline
Scheduler
.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: TakeLast
-
takeLast
@CheckReturnValue @SchedulerSupport("io.reactivex:trampoline") @NonNull public final @NonNull Observable<T> takeLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, boolean delayError)
Returns anObservable
that emits the items from the currentObservable
that were emitted in a specified window of time before the currentObservable
completed.- Scheduler:
takeLast
does not operate on any particular scheduler but uses the current time from thetrampoline
Scheduler
.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
delayError
- iftrue
, an exception signaled by the currentObservable
is delayed until the regular elements are consumed by the downstream; iffalse
, an exception is immediately signaled and all regular elements dropped- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: TakeLast
-
takeLast
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> takeLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits the items from the currentObservable
that were emitted in a specified window of time before the currentObservable
completed, where the timing information is provided by a specifiedScheduler
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
scheduler
- theScheduler
that provides the timestamps for the observed items- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: TakeLast
-
takeLast
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> takeLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean delayError)
Returns anObservable
that emits the items from the currentObservable
that were emitted in a specified window of time before the currentObservable
completed, where the timing information is provided by a specifiedScheduler
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
scheduler
- theScheduler
that provides the timestamps for the observed itemsdelayError
- iftrue
, an exception signaled by the currentObservable
is delayed until the regular elements are consumed by the downstream; iffalse
, an exception is immediately signaled and all regular elements dropped- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: TakeLast
-
takeLast
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> takeLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean delayError, int bufferSize)
Returns anObservable
that emits the items from the currentObservable
that were emitted in a specified window of time before the currentObservable
completed, where the timing information is provided by a specifiedScheduler
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
scheduler
- theScheduler
that provides the timestamps for the observed itemsdelayError
- iftrue
, an exception signaled by the currentObservable
is delayed until the regular elements are consumed by the downstream; iffalse
, an exception is immediately signaled and all regular elements droppedbufferSize
- the hint about how many elements to expect to be last- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: TakeLast
-
takeUntil
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U> @NonNull Observable<T> takeUntil(@NonNull @NonNull ObservableSource<@NonNull U> other)
Returns anObservable
that emits the items emitted by the currentObservable
until a secondObservableSource
emits an item or completes.- Scheduler:
takeUntil
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted byother
- Parameters:
other
- theObservableSource
whose first emitted item or completion will causetakeUntil
to stop emitting items from the currentObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- See Also:
- ReactiveX operators documentation: TakeUntil
-
takeUntil
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> takeUntil(@NonNull @NonNull Predicate<? super @NonNull T> stopPredicate)
Returns anObservable
that emits items emitted by the currentObservable
, checks the specified predicate for each item, and then completes when the condition is satisfied.The difference between this operator and
takeWhile(Predicate)
is that here, the condition is evaluated after the item is emitted.- Scheduler:
takeUntil
does not operate by default on a particularScheduler
.
- Parameters:
stopPredicate
- a function that evaluates an item emitted by the currentObservable
and returns aBoolean
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifstopPredicate
isnull
- Since:
- 1.1.0
- See Also:
- ReactiveX operators documentation: TakeUntil,
takeWhile(Predicate)
-
takeWhile
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> takeWhile(@NonNull @NonNull Predicate<? super @NonNull T> predicate)
Returns anObservable
that emits items emitted by the currentObservable
so long as each item satisfied a specified condition, and then completes as soon as this condition is not satisfied.- Scheduler:
takeWhile
does not operate by default on a particularScheduler
.
- Parameters:
predicate
- a function that evaluates an item emitted by the currentObservable
and returns aBoolean
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
- See Also:
- ReactiveX operators documentation: TakeWhile,
takeUntil(Predicate)
-
throttleFirst
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<T> throttleFirst(long windowDuration, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits only the first item emitted by the currentObservable
during sequential time windows of a specified duration.This differs from
throttleLast(long, java.util.concurrent.TimeUnit)
in that this only tracks passage of time whereasthrottleLast
ticks at scheduled intervals.- Scheduler:
throttleFirst
operates by default on thecomputation
Scheduler
.
- Parameters:
windowDuration
- time to wait before emitting another item after emitting the last itemunit
- the unit of time ofwindowDuration
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Sample
-
throttleFirst
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> throttleFirst(long skipDuration, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits only the first item emitted by the currentObservable
during sequential time windows of a specified duration, where the windows are managed by a specifiedScheduler
.This differs from
throttleLast(long, java.util.concurrent.TimeUnit)
in that this only tracks passage of time whereasthrottleLast
ticks at scheduled intervals.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
skipDuration
- time to wait before emitting another item after emitting the last itemunit
- the unit of time ofskipDuration
scheduler
- theScheduler
to use internally to manage the timers that handle timeout for each event- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Sample
-
throttleFirst
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> throttleFirst(long skipDuration, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, @NonNull @NonNull Consumer<? super @NonNull T> onDropped)
Returns anObservable
that emits only the first item emitted by the currentObservable
during sequential time windows of a specified duration, where the windows are managed by a specifiedScheduler
.This differs from
throttleLast(long, java.util.concurrent.TimeUnit)
in that this only tracks passage of time whereasthrottleLast
ticks at scheduled intervals.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
skipDuration
- time to wait before emitting another item after emitting the last itemunit
- the unit of time ofskipDuration
scheduler
- theScheduler
to use internally to manage the timers that handle timeout for each eventonDropped
- called when an item doesn't get delivered to the downstream- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
oronDropped
isnull
- Since:
- 3.1.6 - Experimental
- See Also:
- ReactiveX operators documentation: Sample
-
throttleLast
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<T> throttleLast(long intervalDuration, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits only the last item emitted by the currentObservable
during sequential time windows of a specified duration.This differs from
throttleFirst(long, java.util.concurrent.TimeUnit)
in that this ticks along at a scheduled interval whereasthrottleFirst
does not tick, it just tracks passage of time.- Scheduler:
throttleLast
operates by default on thecomputation
Scheduler
.
- Parameters:
intervalDuration
- duration of windows within which the last item emitted by the currentObservable
will be emittedunit
- the unit of time ofintervalDuration
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Sample,
sample(long, TimeUnit)
-
throttleLast
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> throttleLast(long intervalDuration, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, @NonNull @NonNull Consumer<? super @NonNull T> onDropped)
Returns anObservable
that emits only the last item emitted by the currentObservable
during sequential time windows of a specified duration, where the duration is governed by a specifiedScheduler
.This differs from
throttleFirst(long, java.util.concurrent.TimeUnit)
in that this ticks along at a scheduled interval whereasthrottleFirst
does not tick, it just tracks passage of time.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
intervalDuration
- duration of windows within which the last item emitted by the currentObservable
will be emittedunit
- the unit of time ofintervalDuration
scheduler
- theScheduler
to use internally to manage the timers that handle timeout for each eventonDropped
- called with the current entry when it has been replaced by a new one- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
oronDropped
isnull
- Since:
- 3.1.6 - Experimental
- See Also:
- ReactiveX operators documentation: Sample,
sample(long, TimeUnit, Scheduler)
-
throttleLast
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> throttleLast(long intervalDuration, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits only the last item emitted by the currentObservable
during sequential time windows of a specified duration, where the duration is governed by a specifiedScheduler
.This differs from
throttleFirst(long, java.util.concurrent.TimeUnit)
in that this ticks along at a scheduled interval whereasthrottleFirst
does not tick, it just tracks passage of time.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
intervalDuration
- duration of windows within which the last item emitted by the currentObservable
will be emittedunit
- the unit of time ofintervalDuration
scheduler
- theScheduler
to use internally to manage the timers that handle timeout for each event- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Sample,
sample(long, TimeUnit, Scheduler)
-
throttleLatest
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<T> throttleLatest(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Throttles items from the currentObservable
by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them.Unlike the option with
throttleLatest(long, TimeUnit, boolean)
, the very last item being held back (if any) is not emitted when the upstream completes.If no items were emitted from the upstream during this timeout phase, the next upstream item is emitted immediately and the timeout window starts from then.
- Scheduler:
throttleLatest
operates by default on thecomputation
Scheduler
.
History: 2.1.14 - experimental
- Parameters:
timeout
- the time to wait after an item emission towards the downstream before trying to emit the latest item from upstream againunit
- the time unit- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- Since:
- 2.2
- See Also:
throttleLatest(long, TimeUnit, boolean)
,throttleLatest(long, TimeUnit, Scheduler)
-
throttleLatest
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<T> throttleLatest(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, boolean emitLast)
Throttles items from the currentObservable
by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them.If no items were emitted from the upstream during this timeout phase, the next upstream item is emitted immediately and the timeout window starts from then.
- Scheduler:
throttleLatest
operates by default on thecomputation
Scheduler
.
History: 2.1.14 - experimental
- Parameters:
timeout
- the time to wait after an item emission towards the downstream before trying to emit the latest item from upstream againunit
- the time unitemitLast
- Iftrue
, the very last item from the upstream will be emitted immediately when the upstream completes, regardless if there is a timeout window active or not. Iffalse
, the very last upstream item is ignored and the flow terminates.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- Since:
- 2.2
- See Also:
throttleLatest(long, TimeUnit, Scheduler, boolean)
-
throttleLatest
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> throttleLatest(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Throttles items from the currentObservable
by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them.Unlike the option with
throttleLatest(long, TimeUnit, Scheduler, boolean)
, the very last item being held back (if any) is not emitted when the upstream completes.If no items were emitted from the upstream during this timeout phase, the next upstream item is emitted immediately and the timeout window starts from then.
- Scheduler:
- You specify which
Scheduler
this operator will use.
History: 2.1.14 - experimental
- Parameters:
timeout
- the time to wait after an item emission towards the downstream before trying to emit the latest item from upstream againunit
- the time unitscheduler
- theScheduler
where the timed wait and latest item emission will be performed- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- Since:
- 2.2
- See Also:
throttleLatest(long, TimeUnit, Scheduler, boolean)
-
throttleLatest
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> throttleLatest(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean emitLast)
Throttles items from the currentObservable
by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them.If no items were emitted from the upstream during this timeout phase, the next upstream item is emitted immediately and the timeout window starts from then.
- Scheduler:
- You specify which
Scheduler
this operator will use.
History: 2.1.14 - experimental
- Parameters:
timeout
- the time to wait after an item emission towards the downstream before trying to emit the latest item from upstream againunit
- the time unitscheduler
- theScheduler
where the timed wait and latest item emission will be performedemitLast
- Iftrue
, the very last item from the upstream will be emitted immediately when the upstream completes, regardless if there is a timeout window active or not. Iffalse
, the very last upstream item is ignored and the flow terminates.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- Since:
- 2.2
-
throttleLatest
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> throttleLatest(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean emitLast, @NonNull @NonNull Consumer<? super @NonNull T> onDropped)
Throttles items from the currentObservable
by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them, invoking the consumer for any dropped item.If no items were emitted from the upstream during this timeout phase, the next upstream item is emitted immediately and the timeout window starts from then.
- Scheduler:
- You specify which
Scheduler
this operator will use. - Error handling:
-
If the upstream signals an
onError
oronDropped
callback crashes, the error is delivered immediately to the downstream. If both happen, aCompositeException
is created, containing both the upstream and the callback error. If theonDropped
callback crashes when the sequence gets disposed, the exception is forwarded to the global error handler viaRxJavaPlugins.onError(Throwable)
.
- Parameters:
timeout
- the time to wait after an item emission towards the downstream before trying to emit the latest item from upstream againunit
- the time unitscheduler
- theScheduler
where the timed wait and latest item emission will be performedemitLast
- Iftrue
, the very last item from the upstream will be emitted immediately when the upstream completes, regardless if there is a timeout window active or not. Iffalse
, the very last upstream item is ignored and the flow terminates.onDropped
- called when an item is replaced by a newer item that doesn't get delivered to the downstream, including the very last item ifemitLast
isfalse
and the current undelivered item when the sequence gets disposed.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
,scheduler
oronDropped
isnull
- Since:
- 3.1.6 - Experimental
-
throttleWithTimeout
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<T> throttleWithTimeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that mirrors the currentObservable
, except that it drops items emitted by the currentObservable
that are followed by newer items before a timeout value expires. The timer resets on each emission (alias todebounce(long, TimeUnit, Scheduler)
).Note: If items keep being emitted by the current
Observable
faster than the timeout then no items will be emitted by the resultingObservable
.- Scheduler:
throttleWithTimeout
operates by default on thecomputation
Scheduler
.
- Parameters:
timeout
- the length of the window of time that must pass after the emission of an item from the currentObservable
, in which the currentObservable
emits no items, in order for the item to be emitted by the resultingObservable
unit
- the unit of time for the specifiedtimeout
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Debounce,
debounce(long, TimeUnit)
-
throttleWithTimeout
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> throttleWithTimeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that mirrors the currentObservable
, except that it drops items emitted by the currentObservable
that are followed by newer items before a timeout value expires on a specifiedScheduler
. The timer resets on each emission (Alias todebounce(long, TimeUnit, Scheduler)
).Note: If items keep being emitted by the current
Observable
faster than the timeout then no items will be emitted by the resultingObservable
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timeout
- the length of the window of time that must pass after the emission of an item from the currentObservable
, in which the currentObservable
emits no items, in order for the item to be emitted by the resultingObservable
unit
- the unit of time for the specifiedtimeout
scheduler
- theScheduler
to use internally to manage the timers that handle the timeout for each item- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Debounce,
debounce(long, TimeUnit, Scheduler)
-
throttleWithTimeout
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> throttleWithTimeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, @NonNull @NonNull Consumer<? super @NonNull T> onDropped)
Returns anObservable
that mirrors the currentObservable
, except that it drops items emitted by the currentObservable
that are followed by newer items before a timeout value expires on a specifiedScheduler
. The timer resets on each emission (Alias todebounce(long, TimeUnit, Scheduler)
).Note: If items keep being emitted by the current
Observable
faster than the timeout then no items will be emitted by the resultingObservable
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timeout
- the length of the window of time that must pass after the emission of an item from the currentObservable
, in which the currentObservable
emits no items, in order for the item to be emitted by the resultingObservable
unit
- the unit of time for the specifiedtimeout
scheduler
- theScheduler
to use internally to manage the timers that handle the timeout for each itemonDropped
- called with the current entry when it has been replaced by a new one- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
oronDropped
isnull
- Since:
- 3.1.6 - Experimental
- See Also:
- ReactiveX operators documentation: Debounce,
debounce(long, TimeUnit, Scheduler, Consumer)
-
timeInterval
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<Timed<T>> timeInterval()
Returns anObservable
that emits records of the time interval between consecutive items emitted by the currentObservable
.- Scheduler:
timeInterval
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.
- Returns:
- the new
Observable
instance - See Also:
- ReactiveX operators documentation: TimeInterval
-
timeInterval
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<Timed<T>> timeInterval(@NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits records of the time interval between consecutive items emitted by the currentObservable
, where this interval is computed on a specifiedScheduler
.- Scheduler:
- The operator does not operate on any particular scheduler but uses the current time
from the specified
Scheduler
.
- Parameters:
scheduler
- theScheduler
used to compute time intervals- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifscheduler
isnull
- See Also:
- ReactiveX operators documentation: TimeInterval
-
timeInterval
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<Timed<T>> timeInterval(@NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits records of the time interval between consecutive items emitted by the currentObservable
.- Scheduler:
timeInterval
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.
- Parameters:
unit
- the time unit for the current time- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: TimeInterval
-
timeInterval
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<Timed<T>> timeInterval(@NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits records of the time interval between consecutive items emitted by the currentObservable
, where this interval is computed on a specifiedScheduler
.- Scheduler:
- The operator does not operate on any particular scheduler but uses the current time
from the specified
Scheduler
.
- Parameters:
unit
- the time unit for the current timescheduler
- theScheduler
used to compute time intervals- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: TimeInterval
-
timeout
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull V> @NonNull Observable<T> timeout(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull V>> itemTimeoutIndicator)
Returns anObservable
that mirrors the currentObservable
, but notifies observers of aTimeoutException
if an item emitted by the currentObservable
doesn't arrive within a window of time after the emission of the previous item, where that period of time is measured by anObservableSource
that is a function of the previous item.Note: The arrival of the first source item is never timed out.
- Scheduler:
- This version of
timeout
operates by default on theimmediate
Scheduler
.
- Type Parameters:
V
- the timeout value type (ignored)- Parameters:
itemTimeoutIndicator
- a function that returns anObservableSource
for each item emitted by the currentObservable
and that determines the timeout window for the subsequent item- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitemTimeoutIndicator
isnull
- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull V> @NonNull Observable<T> timeout(@NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull V>> itemTimeoutIndicator, @NonNull @NonNull ObservableSource<? extends @NonNull T> fallback)
Returns anObservable
that mirrors the currentObservable
, but that switches to a fallbackObservableSource
if an item emitted by the currentObservable
doesn't arrive within a window of time after the emission of the previous item, where that period of time is measured by anObservableSource
that is a function of the previous item.Note: The arrival of the first source item is never timed out.
- Scheduler:
- This version of
timeout
operates by default on theimmediate
Scheduler
.
- Type Parameters:
V
- the timeout value type (ignored)- Parameters:
itemTimeoutIndicator
- a function that returns anObservableSource
, for each item emitted by the currentObservable
, that determines the timeout window for the subsequent itemfallback
- the fallbackObservableSource
to switch to if the currentObservable
times out- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifitemTimeoutIndicator
orfallback
isnull
- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<T> timeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that mirrors the currentObservable
but applies a timeout policy for each emitted item. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the resultingObservable
terminates and notifies observers of aTimeoutException
.- Scheduler:
- This version of
timeout
operates by default on thecomputation
Scheduler
.
- Parameters:
timeout
- maximum duration between emitted items before a timeout occursunit
- the unit of time that applies to thetimeout
argument.- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<T> timeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull ObservableSource<? extends @NonNull T> fallback)
Returns anObservable
that mirrors the currentObservable
but applies a timeout policy for each emitted item. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the currentObservable
is disposed and the resultingObservable
begins instead to mirror a fallbackObservableSource
.- Scheduler:
- This version of
timeout
operates by default on thecomputation
Scheduler
.
- Parameters:
timeout
- maximum duration between items before a timeout occursunit
- the unit of time that applies to thetimeout
argumentfallback
- the fallbackObservableSource
to use in case of a timeout- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orfallback
isnull
- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> timeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, @NonNull @NonNull ObservableSource<? extends @NonNull T> fallback)
Returns anObservable
that mirrors the currentObservable
but applies a timeout policy for each emitted item using a specifiedScheduler
. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the currentObservable
is disposed and returnedObservable
begins instead to mirror a fallbackObservableSource
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timeout
- maximum duration between items before a timeout occursunit
- the unit of time that applies to thetimeout
argumentscheduler
- theScheduler
to run the timeout timers onfallback
- theObservableSource
to use as the fallback in case of a timeout- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
,scheduler
orfallback
isnull
- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> timeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that mirrors the currentObservable
but applies a timeout policy for each emitted item, where this policy is governed on a specifiedScheduler
. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the resultingObservable
terminates and notifies observers of aTimeoutException
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timeout
- maximum duration between items before a timeout occursunit
- the unit of time that applies to thetimeout
argumentscheduler
- theScheduler
to run the timeout timers on- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull V> @NonNull Observable<T> timeout(@NonNull @NonNull ObservableSource<@NonNull U> firstTimeoutIndicator, @NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull V>> itemTimeoutIndicator)
Returns anObservable
that mirrors the currentObservable
, but notifies observers of aTimeoutException
if either the first item emitted by the currentObservable
or any subsequent item doesn't arrive within time windows defined by indicatorObservableSource
s.- Scheduler:
- This version of
timeout
operates by default on theimmediate
Scheduler
.
- Type Parameters:
U
- the first timeout value type (ignored)V
- the subsequent timeout value type (ignored)- Parameters:
firstTimeoutIndicator
- a function that returns anObservableSource
that determines the timeout window for the first source itemitemTimeoutIndicator
- a function that returns anObservableSource
for each item emitted by the currentObservable
and that determines the timeout window in which the subsequent source item must arrive in order to continue the sequence- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- iffirstTimeoutIndicator
oritemTimeoutIndicator
isnull
- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull V> @NonNull Observable<T> timeout(@NonNull @NonNull ObservableSource<@NonNull U> firstTimeoutIndicator, @NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<@NonNull V>> itemTimeoutIndicator, @NonNull @NonNull ObservableSource<? extends @NonNull T> fallback)
Returns anObservable
that mirrors the currentObservable
, but switches to a fallbackObservableSource
if either the first item emitted by the currentObservable
or any subsequent item doesn't arrive within time windows defined by indicatorObservableSource
s.- Scheduler:
- This version of
timeout
operates by default on theimmediate
Scheduler
.
- Type Parameters:
U
- the first timeout value type (ignored)V
- the subsequent timeout value type (ignored)- Parameters:
firstTimeoutIndicator
- a function that returns anObservableSource
which determines the timeout window for the first source itemitemTimeoutIndicator
- a function that returns anObservableSource
for each item emitted by the currentObservable
and that determines the timeout window in which the subsequent source item must arrive in order to continue the sequencefallback
- the fallbackObservableSource
to switch to if the currentObservable
times out- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- iffirstTimeoutIndicator
,itemTimeoutIndicator
orfallback
isnull
- See Also:
- ReactiveX operators documentation: Timeout
-
timeout0
@NonNull private @NonNull Observable<T> timeout0(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @Nullable @Nullable ObservableSource<? extends @NonNull T> fallback, @NonNull @NonNull Scheduler scheduler)
-
timeout0
@NonNull private <U,V> @NonNull Observable<T> timeout0(@NonNull @NonNull ObservableSource<U> firstTimeoutIndicator, @NonNull @NonNull Function<? super @NonNull T,? extends ObservableSource<V>> itemTimeoutIndicator, @Nullable @Nullable ObservableSource<? extends @NonNull T> fallback)
-
timestamp
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<Timed<T>> timestamp()
Returns anObservable
that emits each item emitted by the currentObservable
, wrapped in aTimed
object.- Scheduler:
timestamp
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.
- Returns:
- the new
Observable
instance - See Also:
- ReactiveX operators documentation: Timestamp
-
timestamp
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<Timed<T>> timestamp(@NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits each item emitted by the currentObservable
, wrapped in aTimed
object whose timestamps are provided by a specifiedScheduler
.- Scheduler:
- This operator does not operate on any particular scheduler but uses the current time
from the specified
Scheduler
.
- Parameters:
scheduler
- theScheduler
to use as a time source- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifscheduler
isnull
- See Also:
- ReactiveX operators documentation: Timestamp
-
timestamp
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<Timed<T>> timestamp(@NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits each item emitted by the currentObservable
, wrapped in aTimed
object.- Scheduler:
timestamp
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.
- Parameters:
unit
- the time unit for the current time- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Timestamp
-
timestamp
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<Timed<T>> timestamp(@NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits each item emitted by the currentObservable
, wrapped in aTimed
object whose timestamps are provided by a specifiedScheduler
.- Scheduler:
- This operator does not operate on any particular scheduler but uses the current time
from the specified
Scheduler
.
- Parameters:
unit
- the time unit for the current timescheduler
- theScheduler
to use as a time source- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Timestamp
-
to
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> R to(@NonNull @NonNull ObservableConverter<@NonNull T,? extends @NonNull R> converter)
Calls the specified converter function during assembly time and returns its resulting value.This allows fluent conversion to any other type.
- Scheduler:
to
does not operate by default on a particularScheduler
.
History: 2.1.7 - experimental
- Type Parameters:
R
- the resulting object type- Parameters:
converter
- the function that receives the currentObservable
instance and returns a value- Returns:
- the converted value
- Throws:
java.lang.NullPointerException
- ifconverter
isnull
- Since:
- 2.2
-
toList
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<@NonNull java.util.List<T>> toList()
Returns aSingle
that emits a single item, aList
composed of all the items emitted by the current and finiteObservable
.Normally, an
ObservableSource
that returns multiple items will do so by invoking itsObserver
'sonNext
method for each such item. You can change this behavior by having the operator to compose a list of all of these items and then to invoke theSingleObserver
'sonSuccess
method once, passing it the entire list, by calling theObservable
'stoList
method prior to calling itssubscribe()
method.Note that this operator requires the upstream to signal
onComplete
for the accumulated list to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
toList
does not operate by default on a particularScheduler
.
- Returns:
- the new
Single
instance - See Also:
- ReactiveX operators documentation: To
-
toList
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<@NonNull java.util.List<T>> toList(int capacityHint)
Returns aSingle
that emits a single item, aList
composed of all the items emitted by the current and finiteObservable
.Normally, an
ObservableSource
that returns multiple items will do so by invoking itsObserver
'sonNext
method for each such item. You can change this behavior by having the operator to compose a list of all of these items and then to invoke theSingleObserver
'sonSuccess
method once, passing it the entire list, by calling theObservable
'stoList
method prior to calling itssubscribe()
method.Note that this operator requires the upstream to signal
onComplete
for the accumulated list to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
toList
does not operate by default on a particularScheduler
.
- Parameters:
capacityHint
- the number of elements expected from the currentObservable
- Returns:
- the new
Single
instance - Throws:
java.lang.IllegalArgumentException
- ifcapacityHint
is non-positive- See Also:
- ReactiveX operators documentation: To
-
toList
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Single<U> toList(@NonNull @NonNull Supplier<@NonNull U> collectionSupplier)
Returns aSingle
that emits a single item, aCollection
(subclass) composed of all the items emitted by the finite upstreamObservable
.Normally, an
ObservableSource
that returns multiple items will do so by invoking itsObserver
'sonNext
method for each such item. You can change this behavior by having the operator to compose a collection of all of these items and then to invoke theSingleObserver
'sonSuccess
method once, passing it the entire collection, by calling theObservable
'stoList
method prior to calling itssubscribe()
method.Note that this operator requires the upstream to signal
onComplete
for the accumulated collection to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
toList
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the subclass of a collection of Ts- Parameters:
collectionSupplier
- theSupplier
returning the collection (for each individualObserver
) to be filled in- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifcollectionSupplier
isnull
- See Also:
- ReactiveX operators documentation: To
-
toMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull K> @NonNull Single<@NonNull java.util.Map<K,T>> toMap(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector)
Returns aSingle
that emits a singleHashMap
containing all items emitted by the current and finiteObservable
, mapped by the keys returned by a specifiedkeySelector
function.If more than one source item maps to the same key, the
HashMap
will contain the latest of those items.Note that this operator requires the upstream to signal
onComplete
for the accumulatedHashMap
to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
toMap
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type of the Map- Parameters:
keySelector
- the function that extracts the key from a source item to be used in theHashMap
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
isnull
- See Also:
- ReactiveX operators documentation: To
-
toMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull K,@NonNull V> @NonNull Single<java.util.Map<K,V>> toMap(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector)
Returns aSingle
that emits a singleHashMap
containing values corresponding to items emitted by the current and finiteObservable
, mapped by the keys and values returned by the given selector functions.If more than one source item maps to the same key, the
HashMap
will contain a single entry that corresponds to the latest of those items.Note that this operator requires the upstream to signal
onComplete
for the accumulatedHashMap
to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
toMap
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type of theHashMap
V
- the value type of theHashMap
- Parameters:
keySelector
- the function that extracts the key from a source item to be used in theHashMap
valueSelector
- the function that extracts the value from a source item to be used in theHashMap
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
orvalueSelector
isnull
- See Also:
- ReactiveX operators documentation: To
-
toMap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull K,@NonNull V> @NonNull Single<java.util.Map<K,V>> toMap(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector, @NonNull @NonNull Supplier<? extends java.util.Map<@NonNull K,@NonNull V>> mapSupplier)
Returns aSingle
that emits a singleMap
(subclass), returned by a specifiedmapFactory
function, that contains keys and values extracted from the items, via selector functions, emitted by the current and finiteObservable
.Note that this operator requires the upstream to signal
onComplete
for the accumulatedMap
to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
toMap
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type of theMap
V
- the value type of theMap
- Parameters:
keySelector
- the function that extracts the key from a source item to be used in theMap
valueSelector
- the function that extracts the value from the source items to be used as value in theMap
mapSupplier
- the function that returns aMap
instance to be used- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
,valueSelector
ormapSupplier
isnull
- See Also:
- ReactiveX operators documentation: To
-
toMultimap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull K> @NonNull Single<@NonNull java.util.Map<K,java.util.Collection<T>>> toMultimap(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector)
Returns aSingle
that emits a singleHashMap
that contains anArrayList
of items emitted by the current and finiteObservable
keyed by a specifiedkeySelector
function.Note that this operator requires the upstream to signal
onComplete
for the accumulatedHashMap
to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
toMultimap
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type of theHashMap
- Parameters:
keySelector
- the function that extracts the key from the source items to be used as key in theHashMap
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
isnull
- See Also:
- ReactiveX operators documentation: To
-
toMultimap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull K,@NonNull V> @NonNull Single<@NonNull java.util.Map<K,java.util.Collection<V>>> toMultimap(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, Function<? super @NonNull T,? extends @NonNull V> valueSelector)
Returns aSingle
that emits a singleHashMap
that contains anArrayList
of values extracted by a specifiedvalueSelector
function from items emitted by the current and finiteObservable
, keyed by a specifiedkeySelector
function.Note that this operator requires the upstream to signal
onComplete
for the accumulatedHashMap
to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
toMultimap
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type of theHashMap
V
- the value type of theHashMap
- Parameters:
keySelector
- the function that extracts a key from the source items to be used as key in theHashMap
valueSelector
- the function that extracts a value from the source items to be used as value in theHashMap
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
orvalueSelector
isnull
- See Also:
- ReactiveX operators documentation: To
-
toMultimap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull K,@NonNull V> @NonNull Single<@NonNull java.util.Map<K,java.util.Collection<V>>> toMultimap(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector, @NonNull @NonNull Supplier<? extends java.util.Map<@NonNull K,java.util.Collection<@NonNull V>>> mapSupplier, @NonNull @NonNull Function<? super @NonNull K,? extends java.util.Collection<? super @NonNull V>> collectionFactory)
Returns aSingle
that emits a singleMap
(subclass), returned by a specifiedmapFactory
function, that contains a customCollection
of values, extracted by a specifiedvalueSelector
function from items emitted by the current and finiteObservable
, and keyed by thekeySelector
function.Note that this operator requires the upstream to signal
onComplete
for the accumulatedMap
to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
toMultimap
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type of theMap
V
- the value type of theMap
- Parameters:
keySelector
- the function that extracts a key from the source items to be used as the key in theMap
valueSelector
- the function that extracts a value from the source items to be used as the value in theMap
mapSupplier
- the function that returns aMap
instance to be usedcollectionFactory
- the function that returns aCollection
instance for a particular key to be used in theMap
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
,valueSelector
,mapSupplier
orcollectionFactory
isnull
- See Also:
- ReactiveX operators documentation: To
-
toMultimap
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull K,@NonNull V> @NonNull Single<@NonNull java.util.Map<K,java.util.Collection<V>>> toMultimap(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector, @NonNull @NonNull Supplier<java.util.Map<@NonNull K,java.util.Collection<@NonNull V>>> mapSupplier)
Returns aSingle
that emits a singleMap
(subclass), returned by a specifiedmapFactory
function, that contains anArrayList
of values, extracted by a specifiedvalueSelector
function from items emitted by the current and finiteObservable
and keyed by thekeySelector
function.Note that this operator requires the upstream to signal
onComplete
for the accumulatedMap
to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
toMultimap
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type of theMap
V
- the value type of theMap
- Parameters:
keySelector
- the function that extracts a key from the source items to be used as the key in theMap
valueSelector
- the function that extracts a value from the source items to be used as the value in theMap
mapSupplier
- the function that returns aMap
instance to be used- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
,valueSelector
ormapSupplier
isnull
- See Also:
- ReactiveX operators documentation: To
-
toFlowable
@BackpressureSupport(SPECIAL) @CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> toFlowable(@NonNull @NonNull BackpressureStrategy strategy)
Converts the currentObservable
into aFlowable
by applying the specified backpressure strategy.Marble diagrams for the various backpressure strategies are as follows:
BackpressureStrategy.BUFFER
BackpressureStrategy.DROP
BackpressureStrategy.LATEST
BackpressureStrategy.ERROR
BackpressureStrategy.MISSING
- Backpressure:
- The operator applies the chosen backpressure strategy of
BackpressureStrategy
enum. - Scheduler:
toFlowable
does not operate by default on a particularScheduler
.
- Parameters:
strategy
- the backpressure strategy to apply- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifstrategy
isnull
-
toSortedList
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<@NonNull java.util.List<T>> toSortedList()
Returns aSingle
that emits aList
that contains the items emitted by the current and finiteObservable
, in a sorted order. Each item emitted by the currentObservable
must implementComparable
with respect to all other items in the sequence.If any item emitted by the current
Observable
does not implementComparable
with respect to all other items emitted by the currentObservable
, no items will be emitted and the sequence is terminated with aClassCastException
.Note that this operator requires the upstream to signal
onComplete
for the accumulatedList
to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
toSortedList
does not operate by default on a particularScheduler
.
- Returns:
- the new
Single
instance - See Also:
- ReactiveX operators documentation: To,
toSortedList(int)
,toSortedList(Comparator)
-
toSortedList
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<@NonNull java.util.List<T>> toSortedList(@NonNull @NonNull java.util.Comparator<? super @NonNull T> comparator)
Returns aSingle
that emits aList
that contains the items emitted by the current and finiteObservable
, in a sorted order based on a specified comparison function.Note that this operator requires the upstream to signal
onComplete
for the accumulatedList
to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
toSortedList
does not operate by default on a particularScheduler
.
- Parameters:
comparator
- a function that compares two items emitted by the currentObservable
and returns anint
that indicates their sort order- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifcomparator
isnull
- See Also:
- ReactiveX operators documentation: To
-
toSortedList
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<@NonNull java.util.List<T>> toSortedList(@NonNull @NonNull java.util.Comparator<? super @NonNull T> comparator, int capacityHint)
Returns aSingle
that emits aList
that contains the items emitted by the current and finiteObservable
, in a sorted order based on a specified comparison function.Note that this operator requires the upstream to signal
onComplete
for the accumulatedList
to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
toSortedList
does not operate by default on a particularScheduler
.
- Parameters:
comparator
- a function that compares two items emitted by the currentObservable
and returns anint
that indicates their sort ordercapacityHint
- the initial capacity of theList
used to accumulate items before sorting- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifcomparator
isnull
java.lang.IllegalArgumentException
- ifcapacityHint
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: To
-
toSortedList
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Single<@NonNull java.util.List<T>> toSortedList(int capacityHint)
Returns aSingle
that emits aList
that contains the items emitted by the current and finiteObservable
, in a sorted order. Each item emitted by the currentObservable
must implementComparable
with respect to all other items in the sequence.If any item emitted by the current
Observable
does not implementComparable
with respect to all other items emitted by the currentObservable
, no items will be emitted and the sequence is terminated with aClassCastException
.Note that this operator requires the upstream to signal
onComplete
for the accumulatedList
to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatalOutOfMemoryError
.- Scheduler:
toSortedList
does not operate by default on a particularScheduler
.
- Parameters:
capacityHint
- the initial capacity of theList
used to accumulate items before sorting- Returns:
- the new
Single
instance - Throws:
java.lang.IllegalArgumentException
- ifcapacityHint
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: To,
toSortedList(Comparator, int)
-
unsubscribeOn
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<T> unsubscribeOn(@NonNull @NonNull Scheduler scheduler)
Return anObservable
that schedules the downstreamObserver
s'dispose
calls aimed at the currentObservable
on the givenScheduler
.- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
scheduler
- theScheduler
to perform the call todispose()
of the upstreamDisposable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifscheduler
isnull
- See Also:
- ReactiveX operators documentation: SubscribeOn
-
window
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<Observable<T>> window(long count)
Returns anObservable
that emits windows of items it collects from the currentObservable
. The resultingObservable
emits connected, non-overlapping windows, each containingcount
items. When the currentObservable
completes or encounters an error, the resultingObservable
emits the current window and propagates the notification from the currentObservable
.- Scheduler:
- This version of
window
does not operate by default on a particularScheduler
.
- Parameters:
count
- the maximum size of each window before it should be emitted- Returns:
- the new
Observable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<Observable<T>> window(long count, long skip)
Returns anObservable
that emits windows of items it collects from the currentObservable
. The resultingObservable
emits windows everyskip
items, each containing no more thancount
items. When the currentObservable
completes or encounters an error, the resultingObservable
emits the current window and propagates the notification from the currentObservable
.- Scheduler:
- This version of
window
does not operate by default on a particularScheduler
.
- Parameters:
count
- the maximum size of each window before it should be emittedskip
- how many items need to be skipped before starting a new window. Note that ifskip
andcount
are equal this is the same operation aswindow(long)
.- Returns:
- the new
Observable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
orskip
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull Observable<Observable<T>> window(long count, long skip, int bufferSize)
Returns anObservable
that emits windows of items it collects from the currentObservable
. The resultingObservable
emits windows everyskip
items, each containing no more thancount
items. When the currentObservable
completes or encounters an error, the resultingObservable
emits the current window and propagates the notification from the currentObservable
.- Scheduler:
- This version of
window
does not operate by default on a particularScheduler
.
- Parameters:
count
- the maximum size of each window before it should be emittedskip
- how many items need to be skipped before starting a new window. Note that ifskip
andcount
are equal this is the same operation aswindow(long)
.bufferSize
- the capacity hint for the buffer in the inner windows- Returns:
- the new
Observable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
,skip
orbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<Observable<T>> window(long timespan, long timeskip, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits windows of items it collects from the currentObservable
. The resultingObservable
starts a new window periodically, as determined by thetimeskip
argument. It emits each window after a fixed timespan, specified by thetimespan
argument. When the currentObservable
completes or encounters an error, the resultingObservable
emits the current window and propagates the notification from the currentObservable
.Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.
- Scheduler:
- This version of
window
operates by default on thecomputation
Scheduler
.
- Parameters:
timespan
- the period of time each window collects items before it should be emittedtimeskip
- the period of time after which a new window will be createdunit
- the unit of time that applies to thetimespan
andtimeskip
arguments- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
java.lang.IllegalArgumentException
- iftimespan
ortimeskip
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<Observable<T>> window(long timespan, long timeskip, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits windows of items it collects from the currentObservable
. The resultingObservable
starts a new window periodically, as determined by thetimeskip
argument. It emits each window after a fixed timespan, specified by thetimespan
argument. When the currentObservable
completes or encounters an error, the resultingObservable
emits the current window and propagates the notification from the currentObservable
.Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.
- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timespan
- the period of time each window collects items before it should be emittedtimeskip
- the period of time after which a new window will be createdunit
- the unit of time that applies to thetimespan
andtimeskip
argumentsscheduler
- theScheduler
to use when determining the end and start of a window- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- iftimespan
ortimeskip
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<Observable<T>> window(long timespan, long timeskip, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, int bufferSize)
Returns anObservable
that emits windows of items it collects from the currentObservable
. The resultingObservable
starts a new window periodically, as determined by thetimeskip
argument. It emits each window after a fixed timespan, specified by thetimespan
argument. When the currentObservable
completes or encounters an error, the resultingObservable
emits the current window and propagates the notification from the currentObservable
.Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.
- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timespan
- the period of time each window collects items before it should be emittedtimeskip
- the period of time after which a new window will be createdunit
- the unit of time that applies to thetimespan
andtimeskip
argumentsscheduler
- theScheduler
to use when determining the end and start of a windowbufferSize
- the capacity hint for the buffer in the inner windows- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- iftimespan
,timeskip
orbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<Observable<T>> window(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns anObservable
that emits windows of items it collects from the currentObservable
. The resultingObservable
emits connected, non-overlapping windows, each of a fixed duration specified by thetimespan
argument. When the currentObservable
completes or encounters an error, the resultingObservable
emits the current window and propagates the notification from the currentObservable
.Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.
- Scheduler:
- This version of
window
operates by default on thecomputation
Scheduler
.
- Parameters:
timespan
- the period of time each window collects items before it should be emitted and replaced with a new windowunit
- the unit of time that applies to thetimespan
argument- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<Observable<T>> window(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, long count)
Returns anObservable
that emits windows of items it collects from the currentObservable
. The resultingObservable
emits connected, non-overlapping windows, each of a fixed duration as specified by thetimespan
argument or a maximum size as specified by thecount
argument (whichever is reached first). When the currentObservable
completes or encounters an error, the resultingObservable
emits the current window and propagates the notification from the currentObservable
.Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.
- Scheduler:
- This version of
window
operates by default on thecomputation
Scheduler
.
- Parameters:
timespan
- the period of time each window collects items before it should be emitted and replaced with a new windowunit
- the unit of time that applies to thetimespan
argumentcount
- the maximum size of each window before it should be emitted- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Observable<Observable<T>> window(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, long count, boolean restart)
Returns anObservable
that emits windows of items it collects from the currentObservable
. The resultingObservable
emits connected, non-overlapping windows, each of a fixed duration as specified by thetimespan
argument or a maximum size as specified by thecount
argument (whichever is reached first). When the currentObservable
completes or encounters an error, the resultingObservable
emits the current window and propagates the notification from the currentObservable
.Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.
- Scheduler:
- This version of
window
operates by default on thecomputation
Scheduler
.
- Parameters:
timespan
- the period of time each window collects items before it should be emitted and replaced with a new windowunit
- the unit of time that applies to thetimespan
argumentcount
- the maximum size of each window before it should be emittedrestart
- iftrue
, when a window reaches the capacity limit, the timer is restarted as well- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<Observable<T>> window(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns anObservable
that emits windows of items it collects from the currentObservable
. The resultingObservable
emits connected, non-overlapping windows, each of a fixed duration as specified by thetimespan
argument. When the currentObservable
completes or encounters an error, the resultingObservable
emits the current window and propagates the notification from the currentObservable
.Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.
- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timespan
- the period of time each window collects items before it should be emitted and replaced with a new windowunit
- the unit of time which applies to thetimespan
argumentscheduler
- theScheduler
to use when determining the end and start of a window- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<Observable<T>> window(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, long count)
Returns anObservable
that emits windows of items it collects from the currentObservable
. The resultingObservable
emits connected, non-overlapping windows, each of a fixed duration specified by thetimespan
argument or a maximum size specified by thecount
argument (whichever is reached first). When the currentObservable
completes or encounters an error, the resultingObservable
emits the current window and propagates the notification from the currentObservable
.Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.
- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timespan
- the period of time each window collects items before it should be emitted and replaced with a new windowunit
- the unit of time which applies to thetimespan
argumentcount
- the maximum size of each window before it should be emittedscheduler
- theScheduler
to use when determining the end and start of a window- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<Observable<T>> window(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, long count, boolean restart)
Returns anObservable
that emits windows of items it collects from the currentObservable
. The resultingObservable
emits connected, non-overlapping windows, each of a fixed duration specified by thetimespan
argument or a maximum size specified by thecount
argument (whichever is reached first). When the currentObservable
completes or encounters an error, the resultingObservable
emits the current window and propagates the notification from the currentObservable
.Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.
- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timespan
- the period of time each window collects items before it should be emitted and replaced with a new windowunit
- the unit of time which applies to thetimespan
argumentcount
- the maximum size of each window before it should be emittedscheduler
- theScheduler
to use when determining the end and start of a windowrestart
- iftrue
, when a window reaches the capacity limit, the timer is restarted as well- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @SchedulerSupport("custom") @NonNull public final @NonNull Observable<Observable<T>> window(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, long count, boolean restart, int bufferSize)
Returns anObservable
that emits windows of items it collects from the currentObservable
. The resultingObservable
emits connected, non-overlapping windows, each of a fixed duration specified by thetimespan
argument or a maximum size specified by thecount
argument (whichever is reached first). When the currentObservable
completes or encounters an error, the resultingObservable
emits the current window and propagates the notification from the currentObservable
.Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.
- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timespan
- the period of time each window collects items before it should be emitted and replaced with a new windowunit
- the unit of time which applies to thetimespan
argumentcount
- the maximum size of each window before it should be emittedscheduler
- theScheduler
to use when determining the end and start of a windowrestart
- iftrue
, when a window reaches the capacity limit, the timer is restarted as wellbufferSize
- the capacity hint for the buffer in the inner windows- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifcount
orbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull B> @NonNull Observable<Observable<T>> window(@NonNull @NonNull ObservableSource<@NonNull B> boundaryIndicator)
Returns anObservable
that emits non-overlapping windows of items it collects from the currentObservable
where the boundary of each window is determined by the items emitted from a specified boundary-governingObservableSource
.Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.
- Scheduler:
- This version of
window
does not operate by default on a particularScheduler
.
- Type Parameters:
B
- the window element type (ignored)- Parameters:
boundaryIndicator
- anObservableSource
whose emitted items close and open windows- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifboundaryIndicator
isnull
- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull B> @NonNull Observable<Observable<T>> window(@NonNull @NonNull ObservableSource<@NonNull B> boundaryIndicator, int bufferSize)
Returns anObservable
that emits non-overlapping windows of items it collects from the currentObservable
where the boundary of each window is determined by the items emitted from a specified boundary-governingObservableSource
.Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.
- Scheduler:
- This version of
window
does not operate by default on a particularScheduler
.
- Type Parameters:
B
- the window element type (ignored)- Parameters:
boundaryIndicator
- anObservableSource
whose emitted items close and open windowsbufferSize
- the capacity hint for the buffer in the inner windows- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifboundaryIndicator
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull V> @NonNull Observable<Observable<T>> window(@NonNull @NonNull ObservableSource<@NonNull U> openingIndicator, @NonNull @NonNull Function<? super @NonNull U,? extends ObservableSource<@NonNull V>> closingIndicator)
Returns anObservable
that emits windows of items it collects from the currentObservable
. The resultingObservable
emits windows that contain those items emitted by the currentObservable
between the time when theopeningIndicator
ObservableSource
emits an item and when theObservableSource
returned byclosingIndicator
emits an item.Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.
- Scheduler:
- This version of
window
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the element type of the window-openingObservableSource
V
- the element type of the window-closingObservableSource
s- Parameters:
openingIndicator
- anObservableSource
that, when it emits an item, causes another window to be createdclosingIndicator
- aFunction
that produces anObservableSource
for every window created. When this indicatorObservableSource
emits an item, the associated window is completed- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifopeningIndicator
orclosingIndicator
isnull
- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull V> @NonNull Observable<Observable<T>> window(@NonNull @NonNull ObservableSource<@NonNull U> openingIndicator, @NonNull @NonNull Function<? super @NonNull U,? extends ObservableSource<@NonNull V>> closingIndicator, int bufferSize)
Returns anObservable
that emits windows of items it collects from the currentObservable
. The resultingObservable
emits windows that contain those items emitted by the currentObservable
between the time when theopeningIndicator
ObservableSource
emits an item and when theObservableSource
returned byclosingIndicator
emits an item.Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.
- Scheduler:
- This version of
window
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the element type of the window-openingObservableSource
V
- the element type of the window-closingObservableSource
s- Parameters:
openingIndicator
- anObservableSource
that, when it emits an item, causes another window to be createdclosingIndicator
- aFunction
that produces anObservableSource
for every window created. When this indicatorObservableSource
emits an item, the associated window is completedbufferSize
- the capacity hint for the buffer in the inner windows- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifopeningIndicator
orclosingIndicator
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
withLatestFrom
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull R> @NonNull Observable<R> withLatestFrom(@NonNull @NonNull ObservableSource<? extends @NonNull U> other, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner)
Merges the specifiedObservableSource
into the currentObservable
sequence by using theresultSelector
function only when the currentObservable
emits an item.Note that this operator doesn't emit anything until the other source has produced at least one value. The resulting emission only happens when the current
Observable
emits (and not when the other source emits, unlike combineLatest). If the other source doesn't produce any value and just completes, the sequence is completed immediately. If the upstream completes before the other source has produced at least one value, the sequence completes without emission.- Scheduler:
- This operator, by default, doesn't run any particular
Scheduler
.
- Type Parameters:
U
- the element type of the otherObservableSource
R
- the result type of the combination- Parameters:
other
- the otherObservableSource
combiner
- the function to call when the currentObservable
emits an item and the otherObservableSource
has already emitted an item, to generate the item to be emitted by the resultingObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
orcombiner
isnull
- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: CombineLatest
-
withLatestFrom
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull T1,@NonNull T2,@NonNull R> @NonNull Observable<R> withLatestFrom(@NonNull @NonNull ObservableSource<@NonNull T1> source1, @NonNull @NonNull ObservableSource<@NonNull T2> source2, @NonNull @NonNull Function3<? super @NonNull T,? super @NonNull T1,? super @NonNull T2,@NonNull R> combiner)
Combines the value emission from the currentObservable
with the latest emissions from the otherObservableSource
s via a function to produce the output item.Note that this operator doesn't emit anything until all other sources have produced at least one value. The resulting emission only happens when the current
Observable
emits (and not when any of the other sources emit, unlikecombineLatest
). If a source doesn't produce any value and just completes, the sequence is completed immediately. If the upstream completes before all other sources have produced at least one value, the sequence completes without emission.- Scheduler:
- This operator does not operate by default on a particular
Scheduler
.
- Type Parameters:
T1
- the first other source's value typeT2
- the second other source's value typeR
- the result value type- Parameters:
source1
- the first otherObservableSource
source2
- the second otherObservableSource
combiner
- the function called with an array of values from each participatingObservableSource
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orcombiner
isnull
- Since:
- 2.0
-
withLatestFrom
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull R> @NonNull Observable<R> withLatestFrom(@NonNull @NonNull ObservableSource<@NonNull T1> source1, @NonNull @NonNull ObservableSource<@NonNull T2> source2, @NonNull @NonNull ObservableSource<@NonNull T3> source3, @NonNull @NonNull Function4<? super @NonNull T,? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,@NonNull R> combiner)
Combines the value emission from the currentObservable
with the latest emissions from the otherObservableSource
s via a function to produce the output item.Note that this operator doesn't emit anything until all other sources have produced at least one value. The resulting emission only happens when the current
Observable
emits (and not when any of the other sources emit, unlike combineLatest). If a source doesn't produce any value and just completes, the sequence is completed immediately. If the upstream completes before all other sources have produced at least one value, the sequence completes without emission.- Scheduler:
- This operator does not operate by default on a particular
Scheduler
.
- Type Parameters:
T1
- the first other source's value typeT2
- the second other source's value typeT3
- the third other source's value typeR
- the result value type- Parameters:
source1
- the first otherObservableSource
source2
- the second otherObservableSource
source3
- the third otherObservableSource
combiner
- the function called with an array of values from each participatingObservableSource
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
orcombiner
isnull
- Since:
- 2.0
-
withLatestFrom
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull R> @NonNull Observable<R> withLatestFrom(@NonNull @NonNull ObservableSource<@NonNull T1> source1, @NonNull @NonNull ObservableSource<@NonNull T2> source2, @NonNull @NonNull ObservableSource<@NonNull T3> source3, @NonNull @NonNull ObservableSource<@NonNull T4> source4, @NonNull @NonNull Function5<? super @NonNull T,? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,@NonNull R> combiner)
Combines the value emission from the currentObservable
with the latest emissions from the otherObservableSource
s via a function to produce the output item.Note that this operator doesn't emit anything until all other sources have produced at least one value. The resulting emission only happens when the current
Observable
emits (and not when any of the other sources emit, unlike combineLatest). If a source doesn't produce any value and just completes, the sequence is completed immediately. If the upstream completes before all other sources have produced at least one value, the sequence completes without emission.- Scheduler:
- This operator does not operate by default on a particular
Scheduler
.
- Type Parameters:
T1
- the first other source's value typeT2
- the second other source's value typeT3
- the third other source's value typeT4
- the fourth other source's value typeR
- the result value type- Parameters:
source1
- the first otherObservableSource
source2
- the second otherObservableSource
source3
- the third otherObservableSource
source4
- the fourth otherObservableSource
combiner
- the function called with an array of values from each participatingObservableSource
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
orcombiner
isnull
- Since:
- 2.0
-
withLatestFrom
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> withLatestFrom(@NonNull @NonNull ObservableSource<?>[] others, @NonNull @NonNull Function<? super java.lang.Object[],@NonNull R> combiner)
Combines the value emission from the currentObservable
with the latest emissions from the otherObservableSource
s via a function to produce the output item.Note that this operator doesn't emit anything until all other sources have produced at least one value. The resulting emission only happens when the current
Observable
emits (and not when any of the other sources emit, unlike combineLatest). If a source doesn't produce any value and just completes, the sequence is completed immediately. If the upstream completes before all other sources have produced at least one value, the sequence completes without emission.- Scheduler:
- This operator does not operate by default on a particular
Scheduler
.
- Type Parameters:
R
- the result value type- Parameters:
others
- the array of other sourcescombiner
- the function called with an array of values from each participatingObservableSource
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifothers
orcombiner
isnull
- Since:
- 2.0
-
withLatestFrom
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> withLatestFrom(@NonNull @NonNull java.lang.Iterable<? extends ObservableSource<?>> others, @NonNull @NonNull Function<? super java.lang.Object[],@NonNull R> combiner)
Combines the value emission from the currentObservable
with the latest emissions from the otherObservableSource
s via a function to produce the output item.Note that this operator doesn't emit anything until all other sources have produced at least one value. The resulting emission only happens when the current
Observable
emits (and not when any of the other sources emit, unlikecombineLatest
). If a source doesn't produce any value and just completes, the sequence is completed immediately. If the upstream completes before all other sources have produced at least one value, the sequence completes without emission.- Scheduler:
- This operator does not operate by default on a particular
Scheduler
.
- Type Parameters:
R
- the result value type- Parameters:
others
- the iterable of other sourcescombiner
- the function called with an array of values from each participatingObservableSource
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifothers
orcombiner
isnull
- Since:
- 2.0
-
zipWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull R> @NonNull Observable<R> zipWith(@NonNull @NonNull java.lang.Iterable<@NonNull U> other, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper)
Returns anObservable
that emits items that are the result of applying a specified function to pairs of values, one each from the currentObservable
and a specifiedIterable
sequence.Note that the
other
Iterable
is evaluated as items are observed from the currentObservable
; it is not pre-consumed. This allows you to zip infinite streams on either side.- Scheduler:
zipWith
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items in theother
Iterable
R
- the type of items emitted by the resultingObservable
- Parameters:
other
- theIterable
sequencezipper
- a function that combines the pairs of items from the currentObservable
and theIterable
to generate the items to be emitted by the resultingObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zipWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull R> @NonNull Observable<R> zipWith(@NonNull @NonNull ObservableSource<? extends @NonNull U> other, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper)
Returns anObservable
that emits items that are the result of applying a specified function to pairs of values, one each from the currentObservable
and another specifiedObservableSource
.The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:range(1, 5).doOnComplete(action1).zipWith(range(6, 5).doOnComplete(action2), (a, b) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.- Scheduler:
zipWith
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted by theother
ObservableSource
R
- the type of items emitted by the resultingObservable
- Parameters:
other
- the otherObservableSource
zipper
- a function that combines the pairs of items from the currentObservable
and the otherObservableSource
to generate the items to be emitted by the resultingObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zipWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull R> @NonNull Observable<R> zipWith(@NonNull @NonNull ObservableSource<? extends @NonNull U> other, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper, boolean delayError)
Returns anObservable
that emits items that are the result of applying a specified function to pairs of values, one each from the currentObservable
and another specifiedObservableSource
.The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:range(1, 5).doOnComplete(action1).zipWith(range(6, 5).doOnComplete(action2), (a, b) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.- Scheduler:
zipWith
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted by theother
ObservableSource
R
- the type of items emitted by the resultingObservable
- Parameters:
other
- the otherObservableSource
zipper
- a function that combines the pairs of items from the currentObservable
and the otherObservableSource
to generate the items to be emitted by the resultingObservable
delayError
- iftrue
, errors from the currentObservable
or the otherObservableSource
is delayed until both terminate- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
orzipper
isnull
- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: Zip
-
zipWith
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull R> @NonNull Observable<R> zipWith(@NonNull @NonNull ObservableSource<? extends @NonNull U> other, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper, boolean delayError, int bufferSize)
Returns anObservable
that emits items that are the result of applying a specified function to pairs of values, one each from the currentObservable
and another specifiedObservableSource
.The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:range(1, 5).doOnComplete(action1).zipWith(range(6, 5).doOnComplete(action2), (a, b) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.- Scheduler:
zipWith
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted by theother
ObservableSource
R
- the type of items emitted by the resultingObservable
- Parameters:
other
- the otherObservableSource
zipper
- a function that combines the pairs of items from the currentObservable
and the otherObservableSource
to generate the items to be emitted by the resultingObservable
bufferSize
- the capacity hint for the buffer in the inner windowsdelayError
- iftrue
, errors from the currentObservable
or the otherObservableSource
is delayed until both terminate- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifother
orzipper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: Zip
-
test
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull TestObserver<T> test()
Creates aTestObserver
and subscribes it to the currentObservable
.- Scheduler:
test
does not operate by default on a particularScheduler
.
- Returns:
- the new
TestObserver
instance - Since:
- 2.0
-
test
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull TestObserver<T> test(boolean dispose)
Creates aTestObserver
, optionally disposes it and then subscribes it to the currentObservable
.- Scheduler:
test
does not operate by default on a particularScheduler
.
- Parameters:
dispose
- indicates if theTestObserver
should be disposed before it is subscribed to the currentObservable
- Returns:
- the new
TestObserver
instance - Since:
- 2.0
-
fromOptional
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<@NonNull T> fromOptional(@NonNull @NonNull java.util.Optional<@NonNull T> optional)
Converts the existing value of the provided optional into ajust(Object)
or an empty optional into anempty()
Observable
instance.Note that the operator takes an already instantiated optional reference and does not by any means create this original optional. If the optional is to be created per consumer upon subscription, use
defer(Supplier)
aroundfromOptional
:Observable.defer(() -> Observable.fromOptional(createOptional()));
- Scheduler:
fromOptional
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the element type of the optional value- Parameters:
optional
- the optional value to convert into anObservable
- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifoptional
isnull
- Since:
- 3.0.0
- See Also:
just(Object)
,empty()
-
fromCompletionStage
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<@NonNull T> fromCompletionStage(@NonNull @NonNull java.util.concurrent.CompletionStage<@NonNull T> stage)
Signals the completion value or error of the given (hot)CompletionStage
-based asynchronous calculation.Note that the operator takes an already instantiated, running or terminated
CompletionStage
. If theCompletionStage
is to be created per consumer upon subscription, usedefer(Supplier)
aroundfromCompletionStage
:Observable.defer(() -> Observable.fromCompletionStage(createCompletionStage()));
If the
CompletionStage
completes withnull
, aNullPointerException
is signaled.Canceling the flow can't cancel the execution of the
CompletionStage
becauseCompletionStage
itself doesn't support cancellation. Instead, the operator detaches from theCompletionStage
.- Scheduler:
fromCompletionStage
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the element type of theCompletionStage
- Parameters:
stage
- theCompletionStage
to convert toObservable
and signal its terminal value or error- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifstage
isnull
- Since:
- 3.0.0
-
fromStream
@CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Observable<@NonNull T> fromStream(@NonNull @NonNull java.util.stream.Stream<@NonNull T> stream)
Converts aStream
into a finiteObservable
and emits its items in the sequence.The operator closes the
Stream
upon cancellation and when it terminates. The exceptions raised when closing aStream
are routed to the global error handler (RxJavaPlugins.onError(Throwable)
. If aStream
should not be closed, turn it into anIterable
and usefromIterable(Iterable)
:Stream<T> stream = ... Observable.fromIterable(stream::iterator);
Note that
Stream
s can be consumed only once; any subsequent attempt to consume aStream
will result in anIllegalStateException
.Primitive streams are not supported and items have to be boxed manually (e.g., via
IntStream.boxed()
):IntStream intStream = IntStream.rangeClosed(1, 10); Observable.fromStream(intStream.boxed());
Stream
does not support concurrent usage so creating and/or consuming the same instance multiple times from multiple threads can lead to undefined behavior.- Scheduler:
fromStream
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the element type of the sourceStream
- Parameters:
stream
- theStream
of values to emit- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifstream
isnull
- Since:
- 3.0.0
- See Also:
fromIterable(Iterable)
-
mapOptional
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> mapOptional(@NonNull @NonNull Function<? super @NonNull T,@NonNull java.util.Optional<? extends @NonNull R>> mapper)
Maps each upstream value into anOptional
and emits the contained item if not empty.- Scheduler:
mapOptional
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the non-null
output type- Parameters:
mapper
- the function that receives the upstream item and should return a non-emptyOptional
to emit as the output or an emptyOptional
to skip to the next upstream value- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 3.0.0
- See Also:
map(Function)
,filter(Predicate)
-
collect
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R,@Nullable A> @NonNull Single<R> collect(@NonNull @NonNull java.util.stream.Collector<? super @NonNull T,@Nullable A,@NonNull R> collector)
Collects the finite upstream's values into a container via aStream
Collector
callback set and emits it as the success result as aSingle
.- Scheduler:
collect
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the non-null
result typeA
- the intermediate container type used for the accumulation- Parameters:
collector
- the interface defining the container supplier, accumulator and finisher functions; seeCollectors
for some standard implementations- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifcollector
isnull
- Since:
- 3.0.0
- See Also:
Collectors
,collect(Supplier, BiConsumer)
-
firstStage
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull java.util.concurrent.CompletionStage<T> firstStage(@Nullable @NonNull T defaultItem)
Signals the first upstream item (or the default item if the upstream is empty) via aCompletionStage
.The upstream can be canceled by converting the resulting
CompletionStage
intoCompletableFuture
viaCompletionStage.toCompletableFuture()
and callingCompletableFuture.cancel(boolean)
on it. The upstream will be also cancelled if the resultingCompletionStage
is converted to and completed manually byCompletableFuture.complete(Object)
orCompletableFuture.completeExceptionally(Throwable)
.CompletionStage
s don't have a notion of emptiness and allownull
s, therefore, one can either use adefaultItem
ofnull
or turn the flow into a sequence ofOptional
s and default toOptional.empty()
:CompletionStage<Optional<T>> stage = source.map(Optional::of).firstStage(Optional.empty());
- Scheduler:
firstStage
does not operate by default on a particularScheduler
.
- Parameters:
defaultItem
- the item to signal if the upstream is empty- Returns:
- the new
CompletionStage
instance - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
- Since:
- 3.0.0
- See Also:
firstOrErrorStage()
-
singleStage
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull java.util.concurrent.CompletionStage<T> singleStage(@Nullable @NonNull T defaultItem)
Signals the only expected upstream item (or the default item if the upstream is empty) or signalsIllegalArgumentException
if the upstream has more than one item via aCompletionStage
.The upstream can be canceled by converting the resulting
CompletionStage
intoCompletableFuture
viaCompletionStage.toCompletableFuture()
and callingCompletableFuture.cancel(boolean)
on it. The upstream will be also cancelled if the resultingCompletionStage
is converted to and completed manually byCompletableFuture.complete(Object)
orCompletableFuture.completeExceptionally(Throwable)
.CompletionStage
s don't have a notion of emptiness and allownull
s, therefore, one can either use adefaultItem
ofnull
or turn the flow into a sequence ofOptional
s and default toOptional.empty()
:CompletionStage<Optional<T>> stage = source.map(Optional::of).singleStage(Optional.empty());
- Scheduler:
singleStage
does not operate by default on a particularScheduler
.
- Parameters:
defaultItem
- the item to signal if the upstream is empty- Returns:
- the new
CompletionStage
instance - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
- Since:
- 3.0.0
- See Also:
singleOrErrorStage()
-
lastStage
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull java.util.concurrent.CompletionStage<T> lastStage(@Nullable @NonNull T defaultItem)
Signals the last upstream item (or the default item if the upstream is empty) via aCompletionStage
.The upstream can be canceled by converting the resulting
CompletionStage
intoCompletableFuture
viaCompletionStage.toCompletableFuture()
and callingCompletableFuture.cancel(boolean)
on it. The upstream will be also cancelled if the resultingCompletionStage
is converted to and completed manually byCompletableFuture.complete(Object)
orCompletableFuture.completeExceptionally(Throwable)
.CompletionStage
s don't have a notion of emptiness and allownull
s, therefore, one can either use adefaultItem
ofnull
or turn the flow into a sequence ofOptional
s and default toOptional.empty()
:CompletionStage<Optional<T>> stage = source.map(Optional::of).lastStage(Optional.empty());
- Scheduler:
lastStage
does not operate by default on a particularScheduler
.
- Parameters:
defaultItem
- the item to signal if the upstream is empty- Returns:
- the new
CompletionStage
instance - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
- Since:
- 3.0.0
- See Also:
lastOrErrorStage()
-
firstOrErrorStage
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull java.util.concurrent.CompletionStage<T> firstOrErrorStage()
Signals the first upstream item or aNoSuchElementException
if the upstream is empty via aCompletionStage
.The upstream can be canceled by converting the resulting
CompletionStage
intoCompletableFuture
viaCompletionStage.toCompletableFuture()
and callingCompletableFuture.cancel(boolean)
on it. The upstream will be also cancelled if the resultingCompletionStage
is converted to and completed manually byCompletableFuture.complete(Object)
orCompletableFuture.completeExceptionally(Throwable)
.- Scheduler:
firstOrErrorStage
does not operate by default on a particularScheduler
.
- Returns:
- the new
CompletionStage
instance - Since:
- 3.0.0
- See Also:
firstStage(Object)
-
singleOrErrorStage
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull java.util.concurrent.CompletionStage<T> singleOrErrorStage()
Signals the only expected upstream item, aNoSuchElementException
if the upstream is empty or signalsIllegalArgumentException
if the upstream has more than one item via aCompletionStage
.The upstream can be canceled by converting the resulting
CompletionStage
intoCompletableFuture
viaCompletionStage.toCompletableFuture()
and callingCompletableFuture.cancel(boolean)
on it. The upstream will be also cancelled if the resultingCompletionStage
is converted to and completed manually byCompletableFuture.complete(Object)
orCompletableFuture.completeExceptionally(Throwable)
.- Scheduler:
singleOrErrorStage
does not operate by default on a particularScheduler
.
- Returns:
- the new
CompletionStage
instance - Since:
- 3.0.0
- See Also:
singleStage(Object)
-
lastOrErrorStage
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull java.util.concurrent.CompletionStage<T> lastOrErrorStage()
Signals the last upstream item or aNoSuchElementException
if the upstream is empty via aCompletionStage
.The upstream can be canceled by converting the resulting
CompletionStage
intoCompletableFuture
viaCompletionStage.toCompletableFuture()
and callingCompletableFuture.cancel(boolean)
on it. The upstream will be also cancelled if the resultingCompletionStage
is converted to and completed manually byCompletableFuture.complete(Object)
orCompletableFuture.completeExceptionally(Throwable)
.- Scheduler:
lastOrErrorStage
does not operate by default on a particularScheduler
.
- Returns:
- the new
CompletionStage
instance - Since:
- 3.0.0
- See Also:
lastStage(Object)
-
blockingStream
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull java.util.stream.Stream<T> blockingStream()
Creates a sequentialStream
to consume or process the currentObservable
in a blocking manner via the JavaStream
API.Cancellation of the upstream is done via
BaseStream.close()
, therefore, it is strongly recommended the consumption is performed within a try-with-resources construct:Observable<Integer> source = Observable.range(1, 10) .subscribeOn(Schedulers.computation()); try (Stream<Integer> stream = source.blockingStream()) { stream.limit(3).forEach(System.out::println); }
- Scheduler:
blockingStream
does not operate by default on a particularScheduler
.
- Returns:
- the new
Stream
instance - Since:
- 3.0.0
- See Also:
blockingStream(int)
-
blockingStream
@CheckReturnValue @SchedulerSupport("none") @NonNull public final @NonNull java.util.stream.Stream<T> blockingStream(int capacityHint)
Creates a sequentialStream
to consume or process the currentObservable
in a blocking manner via the JavaStream
API.Cancellation of the upstream is done via
BaseStream.close()
, therefore, it is strongly recommended the consumption is performed within a try-with-resources construct:Observable<Integer> source = Observable.range(1, 10) .subscribeOn(Schedulers.computation()); try (Stream<Integer> stream = source.blockingStream(4)) { stream.limit(3).forEach(System.out::println); }
- Scheduler:
blockingStream
does not operate by default on a particularScheduler
.
- Parameters:
capacityHint
- the expected number of items to be buffered- Returns:
- the new
Stream
instance - Throws:
java.lang.IllegalArgumentException
- ifcapacityHint
is non-positive- Since:
- 3.0.0
-
concatMapStream
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> concatMapStream(@NonNull @NonNull Function<? super @NonNull T,? extends java.util.stream.Stream<? extends @NonNull R>> mapper)
Maps each upstream item into aStream
and emits theStream
's items to the downstream in a sequential fashion.Due to the blocking and sequential nature of Java
Stream
s, the streams are mapped and consumed in a sequential fashion without interleaving (unlike a more generalflatMap(Function)
). Therefore,flatMapStream
andconcatMapStream
are identical operators and are provided as aliases.The operator closes the
Stream
upon cancellation and when it terminates. The exceptions raised when closing aStream
are routed to the global error handler (RxJavaPlugins.onError(Throwable)
. If aStream
should not be closed, turn it into anIterable
and useconcatMapIterable(Function)
:source.concatMapIterable(v -> createStream(v)::iterator);
Note that
Stream
s can be consumed only once; any subsequent attempt to consume aStream
will result in anIllegalStateException
.Primitive streams are not supported and items have to be boxed manually (e.g., via
IntStream.boxed()
):source.concatMapStream(v -> IntStream.rangeClosed(v + 1, v + 10).boxed());
Stream
does not support concurrent usage so creating and/or consuming the same instance multiple times from multiple threads can lead to undefined behavior.- Scheduler:
concatMapStream
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the element type of theStream
s and the result- Parameters:
mapper
- the function that receives an upstream item and should return aStream
whose elements will be emitted to the downstream- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 3.0.0
- See Also:
concatMap(Function)
,concatMapIterable(Function)
,flatMapStream(Function)
-
flatMapStream
@CheckReturnValue @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Observable<R> flatMapStream(@NonNull @NonNull Function<? super @NonNull T,? extends java.util.stream.Stream<? extends @NonNull R>> mapper)
Maps each upstream item into aStream
and emits theStream
's items to the downstream in a sequential fashion.Due to the blocking and sequential nature of Java
Stream
s, the streams are mapped and consumed in a sequential fashion without interleaving (unlike a more generalflatMap(Function)
). Therefore,flatMapStream
andconcatMapStream
are identical operators and are provided as aliases.The operator closes the
Stream
upon cancellation and when it terminates. The exceptions raised when closing aStream
are routed to the global error handler (RxJavaPlugins.onError(Throwable)
. If aStream
should not be closed, turn it into anIterable
and useflatMapIterable(Function)
:source.flatMapIterable(v -> createStream(v)::iterator);
Note that
Stream
s can be consumed only once; any subsequent attempt to consume aStream
will result in anIllegalStateException
.Primitive streams are not supported and items have to be boxed manually (e.g., via
IntStream.boxed()
):source.flatMapStream(v -> IntStream.rangeClosed(v + 1, v + 10).boxed());
Stream
does not support concurrent usage so creating and/or consuming the same instance multiple times from multiple threads can lead to undefined behavior.- Scheduler:
flatMapStream
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the element type of theStream
s and the result- Parameters:
mapper
- the function that receives an upstream item and should return aStream
whose elements will be emitted to the downstream- Returns:
- the new
Observable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 3.0.0
- See Also:
flatMap(Function)
,flatMapIterable(Function)
-
-