T
- the type of the items emitted by the Observablepublic abstract classObservable<T>extendsObjectimplementsObservableSource<T>
Many operators in the class acceptObservableSource
(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 parameterrx2.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 theReactive Streams design and specification by removing any backpressure-related infrastructure and implementation detail, replacing theorg.reactivestreams.Subscription
withDisposable
as the primary means to dispose of a flow.
TheObservable
follows the protocol
onSubscribe onNext* (onError | onComplete)?
where the stream can be disposed through theDisposable
instance provided to consumers throughObserver.onSubscribe
. Unlike theObservable
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();
Flowable
,DisposableObserver
Constructor and Description |
---|
Observable() |
Modifier and Type | Method and Description |
---|---|
Single<Boolean> | all(Predicate<? superT> predicate) Returns a Single that emits a Boolean that indicates whether all of the items emitted by the source ObservableSource satisfy a condition. |
static <T> Observable<T> | amb(Iterable<? extendsObservableSource<? extends T>> sources) Mirrors the one ObservableSource in an Iterable of several ObservableSources that first either emits an item or sends a termination notification. |
static <T> Observable<T> | ambArray(ObservableSource<? extends T>... sources) Mirrors the one ObservableSource in an array of several ObservableSources that first either emits an item or sends a termination notification. |
Observable<T> | ambWith(ObservableSource<? extendsT> other) Mirrors the ObservableSource (current or provided) that first either emits an item or sends a termination notification. |
Single<Boolean> | any(Predicate<? superT> predicate) Returns a Single that emits true if any item emitted by the source ObservableSource satisfies a specified condition, otherwisefalse . |
<R> R | as(ObservableConverter<T,? extends R> converter) Calls the specified converter function during assembly time and returns its resulting value. |
T | blockingFirst() Returns the first item emitted by this Observable , or throwsNoSuchElementException if it emits no items. |
T | blockingFirst(T defaultItem) Returns the first item emitted by this Observable , or a default value if it emits no items. |
void | blockingForEach(Consumer<? superT> onNext) Consumes the upstream Observable in a blocking fashion and invokes the givenConsumer with each upstream item on thecurrent thread until the upstream terminates. |
Iterable<T> | blockingIterable() Converts this Observable into anIterable . |
Iterable<T> | blockingIterable(int bufferSize) Converts this Observable into anIterable . |
T | blockingLast() Returns the last item emitted by this Observable , or throwsNoSuchElementException if thisObservable emits no items. |
T | blockingLast(T defaultItem) Returns the last item emitted by this Observable , or a default value if it emits no items. |
Iterable<T> | blockingLatest() Returns an Iterable that returns the latest item emitted by thisObservable , waiting if necessary for one to become available. |
Iterable<T> | blockingMostRecent(T initialValue) Returns an Iterable that always returns the item most recently emitted by thisObservable . |
Iterable<T> | blockingNext() Returns an Iterable that blocks until thisObservable emits another item, then returns that item. |
T | blockingSingle() If this Observable completes after emitting a single item, return that item, otherwise throw aNoSuchElementException . |
T | blockingSingle(T defaultItem) If this Observable 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. |
void | blockingSubscribe() Runs the source observable to a terminal event, ignoring any values and rethrowing any exception. |
void | blockingSubscribe(Consumer<? superT> onNext) Subscribes to the source and calls the given callbackson the current thread. |
void | blockingSubscribe(Consumer<? superT> onNext,Consumer<? superThrowable> onError) Subscribes to the source and calls the given callbackson the current thread. |
void | blockingSubscribe(Consumer<? superT> onNext,Consumer<? superThrowable> onError,Action onComplete) Subscribes to the source and calls the given callbackson the current thread. |
void | blockingSubscribe(Observer<? superT> observer) Subscribes to the source and calls the Observer methodson the current thread. |
<B> Observable<List<T>> | buffer(Callable<? extendsObservableSource<B>> boundarySupplier) Returns an Observable that emits buffers of items it collects from the source ObservableSource. |
<B,U extendsCollection<? superT>> | buffer(Callable<? extendsObservableSource<B>> boundarySupplier,Callable<U> bufferSupplier) Returns an Observable that emits buffers of items it collects from the source ObservableSource. |
Observable<List<T>> | buffer(int count) Returns an Observable that emits buffers of items it collects from the source ObservableSource. |
<U extendsCollection<? superT>> | buffer(int count,Callable<U> bufferSupplier) Returns an Observable that emits buffers of items it collects from the source ObservableSource. |
Observable<List<T>> | buffer(int count, int skip) Returns an Observable that emits buffers of items it collects from the source ObservableSource. |
<U extendsCollection<? superT>> | buffer(int count, int skip,Callable<U> bufferSupplier) Returns an Observable that emits buffers of items it collects from the source ObservableSource. |
Observable<List<T>> | buffer(long timespan, long timeskip,TimeUnit unit) Returns an Observable that emits buffers of items it collects from the source ObservableSource. |
Observable<List<T>> | buffer(long timespan, long timeskip,TimeUnit unit,Scheduler scheduler) Returns an Observable that emits buffers of items it collects from the source ObservableSource. |
<U extendsCollection<? superT>> | buffer(long timespan, long timeskip,TimeUnit unit,Scheduler scheduler,Callable<U> bufferSupplier) Returns an Observable that emits buffers of items it collects from the source ObservableSource. |
Observable<List<T>> | buffer(long timespan,TimeUnit unit) Returns an Observable that emits buffers of items it collects from the source ObservableSource. |
Observable<List<T>> | buffer(long timespan,TimeUnit unit, int count) Returns an Observable that emits buffers of items it collects from the source ObservableSource. |
Observable<List<T>> | buffer(long timespan,TimeUnit unit,Scheduler scheduler) Returns an Observable that emits buffers of items it collects from the source ObservableSource. |
Observable<List<T>> | buffer(long timespan,TimeUnit unit,Scheduler scheduler, int count) Returns an Observable that emits buffers of items it collects from the source ObservableSource. |
<U extendsCollection<? superT>> | buffer(long timespan,TimeUnit unit,Scheduler scheduler, int count,Callable<U> bufferSupplier, boolean restartTimerOnMaxSize) Returns an Observable that emits buffers of items it collects from the source ObservableSource. |
<TOpening,TClosing> | buffer(ObservableSource<? extends TOpening> openingIndicator,Function<? super TOpening,? extendsObservableSource<? extends TClosing>> closingIndicator) Returns an Observable that emits buffers of items it collects from the source ObservableSource. |
<TOpening,TClosing,U extendsCollection<? superT>> | buffer(ObservableSource<? extends TOpening> openingIndicator,Function<? super TOpening,? extendsObservableSource<? extends TClosing>> closingIndicator,Callable<U> bufferSupplier) Returns an Observable that emits buffers of items it collects from the source ObservableSource. |
<B> Observable<List<T>> | buffer(ObservableSource<B> boundary) Returns an Observable that emits non-overlapping buffered items from the source ObservableSource each time the specified boundary ObservableSource emits an item. |
<B,U extendsCollection<? superT>> | buffer(ObservableSource<B> boundary,Callable<U> bufferSupplier) Returns an Observable that emits non-overlapping buffered items from the source ObservableSource each time the specified boundary ObservableSource emits an item. |
<B> Observable<List<T>> | buffer(ObservableSource<B> boundary, int initialCapacity) Returns an Observable that emits non-overlapping buffered items from the source ObservableSource each time the specified boundary ObservableSource emits an item. |
static int | bufferSize() Returns the default 'island' size or capacity-increment hint for unbounded buffers. |
Observable<T> | cache() Returns an Observable that subscribes to this ObservableSource lazily, caches all of its events and replays them, in the same order as received, to all the downstream subscribers. |
Observable<T> | cacheWithInitialCapacity(int initialCapacity) Returns an Observable that subscribes to this ObservableSource lazily, caches all of its events and replays them, in the same order as received, to all the downstream subscribers. |
<U> Observable<U> | cast(Class<U> clazz) Returns an Observable that emits the items emitted by the source ObservableSource, converted to the specified type. |
<U> Single<U> | collect(Callable<? extends U> initialValueSupplier,BiConsumer<? super U,? superT> collector) Collects items emitted by the finite source ObservableSource into a single mutable data structure and returns a Single that emits this structure. |
<U> Single<U> | collectInto(U initialValue,BiConsumer<? super U,? superT> collector) Collects items emitted by the finite source ObservableSource into a single mutable data structure and returns a Single that emits this structure. |
static <T,R> Observable<R> | combineLatest(Function<? superObject[],? extends R> combiner, int bufferSize,ObservableSource<? extends T>... sources) Combines a collection of source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from any of the source ObservableSources, where this aggregation is defined by a specified function. |
static <T,R> Observable<R> | combineLatest(Iterable<? extendsObservableSource<? extends T>> sources,Function<? superObject[],? extends R> combiner) Combines a collection of source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from any of the source ObservableSources, where this aggregation is defined by a specified function. |
static <T,R> Observable<R> | combineLatest(Iterable<? extendsObservableSource<? extends T>> sources,Function<? superObject[],? extends R> combiner, int bufferSize) Combines a collection of source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from any of the source ObservableSources, where this aggregation is defined by a specified function. |
static <T,R> Observable<R> | combineLatest(ObservableSource<? extends T>[] sources,Function<? superObject[],? extends R> combiner) Combines a collection of source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from any of the source ObservableSources, where this aggregation is defined by a specified function. |
static <T,R> Observable<R> | combineLatest(ObservableSource<? extends T>[] sources,Function<? superObject[],? extends R> combiner, int bufferSize) Combines a collection of source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from any of the source ObservableSources, where this aggregation is defined by a specified function. |
static <T1,T2,R> Observable<R> | combineLatest(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,BiFunction<? super T1,? super T2,? extends R> combiner) Combines two source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from either of the source ObservableSources, where this aggregation is defined by a specified function. |
static <T1,T2,T3,R> | combineLatest(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,Function3<? super T1,? super T2,? super T3,? extends R> combiner) Combines three source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from any of the source ObservableSources, where this aggregation is defined by a specified function. |
static <T1,T2,T3,T4,R> | combineLatest(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,Function4<? super T1,? super T2,? super T3,? super T4,? extends R> combiner) Combines four source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from any of the source ObservableSources, where this aggregation is defined by a specified function. |
static <T1,T2,T3,T4,T5,R> | combineLatest(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,Function5<? super T1,? super T2,? super T3,? super T4,? super T5,? extends R> combiner) Combines five source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from any of the source ObservableSources, where this aggregation is defined by a specified function. |
static <T1,T2,T3,T4,T5,T6,R> | combineLatest(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,ObservableSource<? extends T6> source6,Function6<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? extends R> combiner) Combines six source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from any of the source ObservableSources, where this aggregation is defined by a specified function. |
static <T1,T2,T3,T4,T5,T6,T7,R> | combineLatest(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,ObservableSource<? extends T6> source6,ObservableSource<? extends T7> source7,Function7<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? extends R> combiner) Combines seven source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from any of the source ObservableSources, where this aggregation is defined by a specified function. |
static <T1,T2,T3,T4,T5,T6,T7,T8,R> | combineLatest(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,ObservableSource<? extends T6> source6,ObservableSource<? extends T7> source7,ObservableSource<? extends T8> source8,Function8<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? extends R> combiner) Combines eight source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from any of the source ObservableSources, where this aggregation is defined by a specified function. |
static <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> | combineLatest(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,ObservableSource<? extends T6> source6,ObservableSource<? extends T7> source7,ObservableSource<? extends T8> source8,ObservableSource<? extends T9> source9,Function9<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? super T9,? extends R> combiner) Combines nine source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from any of the source ObservableSources, where this aggregation is defined by a specified function. |
static <T,R> Observable<R> | combineLatestDelayError(Function<? superObject[],? extends R> combiner, int bufferSize,ObservableSource<? extends T>... sources) Combines a collection of source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from any of the source ObservableSources, where this aggregation is defined by a specified function and delays any error from the sources until all source ObservableSources terminate. |
static <T,R> Observable<R> | combineLatestDelayError(Iterable<? extendsObservableSource<? extends T>> sources,Function<? superObject[],? extends R> combiner) Combines a collection of source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from any of the source ObservableSources, where this aggregation is defined by a specified function and delays any error from the sources until all source ObservableSources terminate. |
static <T,R> Observable<R> | combineLatestDelayError(Iterable<? extendsObservableSource<? extends T>> sources,Function<? superObject[],? extends R> combiner, int bufferSize) Combines a collection of source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from any of the source ObservableSources, where this aggregation is defined by a specified function and delays any error from the sources until all source ObservableSources terminate. |
static <T,R> Observable<R> | combineLatestDelayError(ObservableSource<? extends T>[] sources,Function<? superObject[],? extends R> combiner) Combines a collection of source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from any of the source ObservableSources, where this aggregation is defined by a specified function. |
static <T,R> Observable<R> | combineLatestDelayError(ObservableSource<? extends T>[] sources,Function<? superObject[],? extends R> combiner, int bufferSize) Combines a collection of source ObservableSources by emitting an item that aggregates the latest values of each of the source ObservableSources each time an item is received from any of the source ObservableSources, where this aggregation is defined by a specified function and delays any error from the sources until all source ObservableSources terminate. |
<R> Observable<R> | compose(ObservableTransformer<? superT,? extends R> composer) Transform an ObservableSource by applying a particular Transformer function to it. |
static <T> Observable<T> | concat(Iterable<? extendsObservableSource<? extends T>> sources) Concatenates elements of each ObservableSource provided via an Iterable sequence into a single sequence of elements without interleaving them. |
static <T> Observable<T> | concat(ObservableSource<? extendsObservableSource<? extends T>> sources) Returns an Observable that emits the items emitted by each of the ObservableSources emitted by the source ObservableSource, one after the other, without interleaving them. |
static <T> Observable<T> | concat(ObservableSource<? extendsObservableSource<? extends T>> sources, int prefetch) Returns an Observable that emits the items emitted by each of the ObservableSources emitted by the source ObservableSource, one after the other, without interleaving them. |
static <T> Observable<T> | concat(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2) Returns an Observable that emits the items emitted by two ObservableSources, one after the other, without interleaving them. |
static <T> Observable<T> | concat(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2,ObservableSource<? extends T> source3) Returns an Observable that emits the items emitted by three ObservableSources, one after the other, without interleaving them. |
static <T> Observable<T> | concat(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2,ObservableSource<? extends T> source3,ObservableSource<? extends T> source4) Returns an Observable that emits the items emitted by four ObservableSources, one after the other, without interleaving them. |
static <T> Observable<T> | concatArray(ObservableSource<? extends T>... sources) Concatenates a variable number of ObservableSource sources. |
static <T> Observable<T> | concatArrayDelayError(ObservableSource<? extends T>... sources) Concatenates a variable number of ObservableSource sources and delays errors from any of them till all terminate. |
static <T> Observable<T> | concatArrayEager(int maxConcurrency, int prefetch,ObservableSource<? extends T>... sources) Concatenates an array of ObservableSources eagerly into a single stream of values. |
static <T> Observable<T> | concatArrayEager(ObservableSource<? extends T>... sources) Concatenates an array of ObservableSources eagerly into a single stream of values. |
static <T> Observable<T> | concatArrayEagerDelayError(int maxConcurrency, int prefetch,ObservableSource<? extends T>... sources) Concatenates an array of ObservableSource s eagerly into a single stream of values and delaying any errors until all sources terminate. |
static <T> Observable<T> | concatArrayEagerDelayError(ObservableSource<? extends T>... sources) Concatenates an array of ObservableSource s eagerly into a single stream of values and delaying any errors until all sources terminate. |
static <T> Observable<T> | concatDelayError(Iterable<? extendsObservableSource<? extends T>> sources) Concatenates the Iterable sequence of ObservableSources into a single sequence by subscribing to each ObservableSource, one after the other, one at a time and delays any errors till the all inner ObservableSources terminate. |
static <T> Observable<T> | concatDelayError(ObservableSource<? extendsObservableSource<? extends T>> sources) Concatenates the ObservableSource sequence of ObservableSources into a single sequence by subscribing to each inner ObservableSource, one after the other, one at a time and delays any errors till the all inner and the outer ObservableSources terminate. |
static <T> Observable<T> | concatDelayError(ObservableSource<? extendsObservableSource<? extends T>> sources, int prefetch, boolean tillTheEnd) Concatenates the ObservableSource sequence of ObservableSources into a single sequence by subscribing to each inner ObservableSource, one after the other, one at a time and delays any errors till the all inner and the outer ObservableSources terminate. |
static <T> Observable<T> | concatEager(Iterable<? extendsObservableSource<? extends T>> sources) Concatenates a sequence of ObservableSources eagerly into a single stream of values. |
static <T> Observable<T> | concatEager(Iterable<? extendsObservableSource<? extends T>> sources, int maxConcurrency, int prefetch) Concatenates a sequence of ObservableSources eagerly into a single stream of values. |
static <T> Observable<T> | concatEager(ObservableSource<? extendsObservableSource<? extends T>> sources) Concatenates an ObservableSource sequence of ObservableSources eagerly into a single stream of values. |
static <T> Observable<T> | concatEager(ObservableSource<? extendsObservableSource<? extends T>> sources, int maxConcurrency, int prefetch) Concatenates an ObservableSource sequence of ObservableSources eagerly into a single stream of values. |
<R> Observable<R> | concatMap(Function<? superT,? extendsObservableSource<? extends R>> mapper) Returns a new Observable that emits items resulting from applying a function that you supply to each item emitted by the source ObservableSource, where that function returns an ObservableSource, and then emitting the items that result from concatenating those resulting ObservableSources. |
<R> Observable<R> | concatMap(Function<? superT,? extendsObservableSource<? extends R>> mapper, int prefetch) Returns a new Observable that emits items resulting from applying a function that you supply to each item emitted by the source ObservableSource, where that function returns an ObservableSource, and then emitting the items that result from concatenating those resulting ObservableSources. |
Completable | concatMapCompletable(Function<? superT,? extendsCompletableSource> mapper) Maps each element of the upstream Observable into CompletableSources, subscribes to them one at a time in order and waits until the upstream and all CompletableSources complete. |
Completable | concatMapCompletable(Function<? superT,? extendsCompletableSource> mapper, int capacityHint) Maps each element of the upstream Observable into CompletableSources, subscribes to them one at a time in order and waits until the upstream and all CompletableSources complete. |
Completable | concatMapCompletableDelayError(Function<? superT,? extendsCompletableSource> mapper) Maps the upstream items into CompletableSource s and subscribes to them one after the other terminates, delaying all errors till both thisObservable and all innerCompletableSource s terminate. |
Completable | concatMapCompletableDelayError(Function<? superT,? extendsCompletableSource> mapper, boolean tillTheEnd) Maps the upstream items into CompletableSource s and subscribes to them one after the other terminates, optionally delaying all errors till both thisObservable and all innerCompletableSource s terminate. |
Completable | concatMapCompletableDelayError(Function<? superT,? extendsCompletableSource> mapper, boolean tillTheEnd, int prefetch) Maps the upstream items into CompletableSource s and subscribes to them one after the other terminates, optionally delaying all errors till both thisObservable and all innerCompletableSource s terminate. |
<R> Observable<R> | concatMapDelayError(Function<? superT,? extendsObservableSource<? extends R>> mapper) Maps each of the items into an ObservableSource, 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 inner ObservableSources till all of them terminate. |
<R> Observable<R> | concatMapDelayError(Function<? superT,? extendsObservableSource<? extends R>> mapper, int prefetch, boolean tillTheEnd) Maps each of the items into an ObservableSource, 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 inner ObservableSources till all of them terminate. |
<R> Observable<R> | concatMapEager(Function<? superT,? extendsObservableSource<? extends R>> mapper) Maps a sequence of values into ObservableSources and concatenates these ObservableSources eagerly into a single ObservableSource. |
<R> Observable<R> | concatMapEager(Function<? superT,? extendsObservableSource<? extends R>> mapper, int maxConcurrency, int prefetch) Maps a sequence of values into ObservableSources and concatenates these ObservableSources eagerly into a single ObservableSource. |
<R> Observable<R> | concatMapEagerDelayError(Function<? superT,? extendsObservableSource<? extends R>> mapper, boolean tillTheEnd) Maps a sequence of values into ObservableSources and concatenates these ObservableSources eagerly into a single ObservableSource. |
<R> Observable<R> | concatMapEagerDelayError(Function<? superT,? extendsObservableSource<? extends R>> mapper, int maxConcurrency, int prefetch, boolean tillTheEnd) Maps a sequence of values into ObservableSources and concatenates these ObservableSources eagerly into a single ObservableSource. |
<U> Observable<U> | concatMapIterable(Function<? superT,? extendsIterable<? extends U>> mapper) Returns an Observable that concatenate each item emitted by the source ObservableSource with the values in an Iterable corresponding to that item that is generated by a selector. |
<U> Observable<U> | concatMapIterable(Function<? superT,? extendsIterable<? extends U>> mapper, int prefetch) Returns an Observable that concatenate each item emitted by the source ObservableSource with the values in an Iterable corresponding to that item that is generated by a selector. |
<R> Observable<R> | concatMapMaybe(Function<? superT,? extendsMaybeSource<? extends R>> mapper) Maps the upstream items into MaybeSource s and subscribes to them one after the other succeeds or completes, emits their success value if available or terminates immediately if either thisObservable or the current innerMaybeSource fail. |
<R> Observable<R> | concatMapMaybe(Function<? superT,? extendsMaybeSource<? extends R>> mapper, int prefetch) Maps the upstream items into MaybeSource s and subscribes to them one after the other succeeds or completes, emits their success value if available or terminates immediately if either thisObservable or the current innerMaybeSource fail. |
<R> Observable<R> | concatMapMaybeDelayError(Function<? superT,? extendsMaybeSource<? extends R>> mapper) Maps the upstream items into MaybeSource s and subscribes to them one after the other terminates, emits their success value if available and delaying all errors till both thisObservable and all innerMaybeSource s terminate. |
<R> Observable<R> | concatMapMaybeDelayError(Function<? superT,? extendsMaybeSource<? extends R>> mapper, boolean tillTheEnd) Maps the upstream items into MaybeSource s and subscribes to them one after the other terminates, emits their success value if available and optionally delaying all errors till both thisObservable and all innerMaybeSource s terminate. |
<R> Observable<R> | concatMapMaybeDelayError(Function<? superT,? extendsMaybeSource<? extends R>> mapper, boolean tillTheEnd, int prefetch) Maps the upstream items into MaybeSource s and subscribes to them one after the other terminates, emits their success value if available and optionally delaying all errors till both thisObservable and all innerMaybeSource s terminate. |
<R> Observable<R> | concatMapSingle(Function<? superT,? extendsSingleSource<? extends R>> mapper) Maps the upstream items into SingleSource s and subscribes to them one after the other succeeds, emits their success values or terminates immediately if either thisObservable or the current innerSingleSource fail. |
<R> Observable<R> | concatMapSingle(Function<? superT,? extendsSingleSource<? extends R>> mapper, int prefetch) Maps the upstream items into SingleSource s and subscribes to them one after the other succeeds, emits their success values or terminates immediately if either thisObservable or the current innerSingleSource fail. |
<R> Observable<R> | concatMapSingleDelayError(Function<? superT,? extendsSingleSource<? extends R>> mapper) Maps the upstream items into SingleSource s and subscribes to them one after the other succeeds or fails, emits their success values and delays all errors till both thisObservable and all innerSingleSource s terminate. |
<R> Observable<R> | concatMapSingleDelayError(Function<? superT,? extendsSingleSource<? extends R>> mapper, boolean tillTheEnd) Maps the upstream items into SingleSource s and subscribes to them one after the other succeeds or fails, emits their success values and optionally delays all errors till both thisObservable and all innerSingleSource s terminate. |
<R> Observable<R> | concatMapSingleDelayError(Function<? superT,? extendsSingleSource<? extends R>> mapper, boolean tillTheEnd, int prefetch) Maps the upstream items into SingleSource s and subscribes to them one after the other succeeds or fails, emits their success values and optionally delays errors till both thisObservable and all innerSingleSource s terminate. |
Observable<T> | concatWith(CompletableSource other) Returns an Observable that emits items from thisObservable and when it completes normally, the otherCompletableSource is subscribed to and the returnedObservable emits its terminal events. |
Observable<T> | concatWith(MaybeSource<? extendsT> other) Returns an Observable that emits the items from thisObservable followed by the success item or terminal events of the otherMaybeSource . |
Observable<T> | concatWith(ObservableSource<? extendsT> other) Returns an Observable that emits the items emitted from the current ObservableSource, then the next, one after the other, without interleaving them. |
Observable<T> | concatWith(SingleSource<? extendsT> other) Returns an Observable that emits the items from thisObservable followed by the success item or error event of the otherSingleSource . |
Single<Boolean> | contains(Object element) Returns a Single that emits a Boolean that indicates whether the source ObservableSource emitted a specified item. |
Single<Long> | count() Returns a Single that counts the total number of items emitted by the source ObservableSource and emits this count as a 64-bit Long. |
static <T> Observable<T> | create(ObservableOnSubscribe<T> source) Provides an API (via a cold Observable) that bridges the reactive world with the callback-style world. |
<U> Observable<T> | debounce(Function<? superT,? extendsObservableSource<U>> debounceSelector) Returns an Observable that mirrors the source ObservableSource, except that it drops items emitted by the source ObservableSource that are followed by another item within a computed debounce duration. |
Observable<T> | debounce(long timeout,TimeUnit unit) Returns an Observable that mirrors the source ObservableSource, except that it drops items emitted by the source ObservableSource that are followed by newer items before a timeout value expires. |
Observable<T> | debounce(long timeout,TimeUnit unit,Scheduler scheduler) Returns an Observable that mirrors the source ObservableSource, except that it drops items emitted by the source ObservableSource that are followed by newer items before a timeout value expires on a specified Scheduler. |
Observable<T> | defaultIfEmpty(T defaultItem) Returns an Observable that emits the items emitted by the source ObservableSource or a specified default item if the source ObservableSource is empty. |
static <T> Observable<T> | defer(Callable<? extendsObservableSource<? extends T>> supplier) Returns an Observable that calls an ObservableSource factory to create an ObservableSource for each new Observer that subscribes. |
<U> Observable<T> | delay(Function<? superT,? extendsObservableSource<U>> itemDelay) Returns an Observable that delays the emissions of the source ObservableSource via another ObservableSource on a per-item basis. |
Observable<T> | delay(long delay,TimeUnit unit) Returns an Observable that emits the items emitted by the source ObservableSource shifted forward in time by a specified delay. |
Observable<T> | delay(long delay,TimeUnit unit, boolean delayError) Returns an Observable that emits the items emitted by the source ObservableSource shifted forward in time by a specified delay. |
Observable<T> | delay(long delay,TimeUnit unit,Scheduler scheduler) Returns an Observable that emits the items emitted by the source ObservableSource shifted forward in time by a specified delay. |
Observable<T> | delay(long delay,TimeUnit unit,Scheduler scheduler, boolean delayError) Returns an Observable that emits the items emitted by the source ObservableSource shifted forward in time by a specified delay. |
<U,V> Observable<T> | delay(ObservableSource<U> subscriptionDelay,Function<? superT,? extendsObservableSource<V>> itemDelay) Returns an Observable that delays the subscription to and emissions from the source ObservableSource via another ObservableSource on a per-item basis. |
Observable<T> | delaySubscription(long delay,TimeUnit unit) Returns an Observable that delays the subscription to the source ObservableSource by a given amount of time. |
Observable<T> | delaySubscription(long delay,TimeUnit unit,Scheduler scheduler) Returns an Observable that delays the subscription to the source ObservableSource by a given amount of time, both waiting and subscribing on a given Scheduler. |
<U> Observable<T> | delaySubscription(ObservableSource<U> other) Returns an Observable that delays the subscription to this Observable until the other Observable emits an element or completes normally. |
<T2> Observable<T2> | dematerialize() Deprecated. in 2.2.4; inherently type-unsafe as it overrides the output generic type. Use dematerialize(Function) instead. |
<R> Observable<R> | dematerialize(Function<? superT,Notification<R>> selector) Returns an Observable that reverses the effect of materialize by transforming theNotification objects extracted from the source items via a selector function into their respectiveObserver signal types. |
Observable<T> | distinct() Returns an Observable that emits all items emitted by the source ObservableSource that are distinct based on Object.equals(Object) comparison. |
<K> Observable<T> | distinct(Function<? superT,K> keySelector) Returns an Observable that emits all items emitted by the source ObservableSource that are distinct according to a key selector function and based on Object.equals(Object) comparison of the objects returned by the key selector function. |
<K> Observable<T> | distinct(Function<? superT,K> keySelector,Callable<? extendsCollection<? super K>> collectionSupplier) Returns an Observable that emits all items emitted by the source ObservableSource that are distinct according to a key selector function and based on Object.equals(Object) comparison of the objects returned by the key selector function. |
Observable<T> | distinctUntilChanged() Returns an Observable that emits all items emitted by the source ObservableSource that are distinct from their immediate predecessors based on Object.equals(Object) comparison. |
Observable<T> | distinctUntilChanged(BiPredicate<? superT,? superT> comparer) Returns an Observable that emits all items emitted by the source ObservableSource that are distinct from their immediate predecessors when compared with each other via the provided comparator function. |
<K> Observable<T> | distinctUntilChanged(Function<? superT,K> keySelector) Returns an Observable that emits all items emitted by the source ObservableSource that are distinct from their immediate predecessors, according to a key selector function and based on Object.equals(Object) comparison of those objects returned by the key selector function. |
Observable<T> | doAfterNext(Consumer<? superT> onAfterNext) Calls the specified consumer with the current item after this item has been emitted to the downstream. |
Observable<T> | doAfterTerminate(Action onFinally) |
Observable<T> | doFinally(Action onFinally) Calls the specified action after this Observable signals onError or onCompleted or gets disposed by the downstream. |
Observable<T> | doOnComplete(Action onComplete) Modifies the source ObservableSource so that it invokes an action when it calls onComplete . |
Observable<T> | doOnDispose(Action onDispose) Calls the dispose Action if the downstream disposes the sequence. |
Observable<T> | doOnEach(Consumer<? superNotification<T>> onNotification) Modifies the source ObservableSource so that it invokes an action for each item it emits. |
Observable<T> | doOnEach(Observer<? superT> observer) Modifies the source ObservableSource so that it notifies an Observer for each item and terminal event it emits. |
Observable<T> | doOnError(Consumer<? superThrowable> onError) Modifies the source ObservableSource so that it invokes an action if it calls onError . |
Observable<T> | doOnLifecycle(Consumer<? superDisposable> onSubscribe,Action onDispose) Calls the appropriate onXXX method (shared between all Observer) for the lifecycle events of the sequence (subscription, disposal). |
Observable<T> | doOnNext(Consumer<? superT> onNext) Modifies the source ObservableSource so that it invokes an action when it calls onNext . |
Observable<T> | doOnSubscribe(Consumer<? superDisposable> onSubscribe) Modifies the source ObservableSource so that it invokes the given action when it is subscribed from its subscribers. |
Observable<T> | doOnTerminate(Action onTerminate) Modifies the source ObservableSource so that it invokes an action when it calls onComplete oronError . |
Maybe<T> | elementAt(long index) Returns a Maybe that emits the single item at a specified index in a sequence of emissions from this Observable or completes if this Observable signals fewer elements than index. |
Single<T> | elementAt(long index,T defaultItem) Returns a Single that emits the item found at a specified index in a sequence of emissions from this Observable, or a default item if that index is out of range. |
Single<T> | elementAtOrError(long index) Returns a Single that emits the item found at a specified index in a sequence of emissions from this Observable or signals a NoSuchElementException if this Observable signals fewer elements than index. |
static <T> Observable<T> | empty() Returns an Observable that emits no items to the Observer and immediately invokes itsonComplete method. |
static <T> Observable<T> | error(Callable<? extendsThrowable> errorSupplier) |
static <T> Observable<T> | error(Throwable exception) |
Observable<T> | filter(Predicate<? superT> predicate) Filters items emitted by an ObservableSource by only emitting those that satisfy a specified predicate. |
Single<T> | first(T defaultItem) Returns a Single that emits only the very first item emitted by the source ObservableSource, or a default item if the source ObservableSource completes without emitting any items. |
Maybe<T> | firstElement() Returns a Maybe that emits only the very first item emitted by the source ObservableSource, or completes if the source ObservableSource is empty. |
Single<T> | firstOrError() Returns a Single that emits only the very first item emitted by this Observable or signals a NoSuchElementException if this Observable is empty. |
<R> Observable<R> | flatMap(Function<? superT,? extendsObservableSource<? extends R>> mapper) Returns an Observable that emits items based on applying a function that you supply to each item emitted by the source ObservableSource, where that function returns an ObservableSource, and then merging those resulting ObservableSources and emitting the results of this merger. |
<R> Observable<R> | flatMap(Function<? superT,? extendsObservableSource<? extends R>> mapper, boolean delayErrors) Returns an Observable that emits items based on applying a function that you supply to each item emitted by the source ObservableSource, where that function returns an ObservableSource, and then merging those resulting ObservableSources and emitting the results of this merger. |
<R> Observable<R> | flatMap(Function<? superT,? extendsObservableSource<? extends R>> mapper, boolean delayErrors, int maxConcurrency) Returns an Observable that emits items based on applying a function that you supply to each item emitted by the source ObservableSource, where that function returns an ObservableSource, and then merging those resulting ObservableSources and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to these ObservableSources. |
<R> Observable<R> | flatMap(Function<? superT,? extendsObservableSource<? extends R>> mapper, boolean delayErrors, int maxConcurrency, int bufferSize) Returns an Observable that emits items based on applying a function that you supply to each item emitted by the source ObservableSource, where that function returns an ObservableSource, and then merging those resulting ObservableSources and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to these ObservableSources. |
<R> Observable<R> | flatMap(Function<? superT,? extendsObservableSource<? extends R>> onNextMapper,Function<? superThrowable,? extendsObservableSource<? extends R>> onErrorMapper,Callable<? extendsObservableSource<? extends R>> onCompleteSupplier) Returns an Observable that applies a function to each item emitted or notification raised by the source ObservableSource and then flattens the ObservableSources returned from these functions and emits the resulting items. |
<R> Observable<R> | flatMap(Function<? superT,? extendsObservableSource<? extends R>> onNextMapper,Function<Throwable,? extendsObservableSource<? extends R>> onErrorMapper,Callable<? extendsObservableSource<? extends R>> onCompleteSupplier, int maxConcurrency) Returns an Observable that applies a function to each item emitted or notification raised by the source ObservableSource and then flattens the ObservableSources returned from these functions and emits the resulting items, while limiting the maximum number of concurrent subscriptions to these ObservableSources. |
<R> Observable<R> | flatMap(Function<? superT,? extendsObservableSource<? extends R>> mapper, int maxConcurrency) Returns an Observable that emits items based on applying a function that you supply to each item emitted by the source ObservableSource, where that function returns an ObservableSource, and then merging those resulting ObservableSources and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to these ObservableSources. |
<U,R> Observable<R> | flatMap(Function<? superT,? extendsObservableSource<? extends U>> mapper,BiFunction<? superT,? super U,? extends R> resultSelector) Returns an Observable that emits the results of a specified function to the pair of values emitted by the source ObservableSource and a specified collection ObservableSource. |
<U,R> Observable<R> | flatMap(Function<? superT,? extendsObservableSource<? extends U>> mapper,BiFunction<? superT,? super U,? extends R> combiner, boolean delayErrors) Returns an Observable that emits the results of a specified function to the pair of values emitted by the source ObservableSource and a specified collection ObservableSource. |
<U,R> Observable<R> | flatMap(Function<? superT,? extendsObservableSource<? extends U>> mapper,BiFunction<? superT,? super U,? extends R> combiner, boolean delayErrors, int maxConcurrency) Returns an Observable that emits the results of a specified function to the pair of values emitted by the source ObservableSource and a specified collection ObservableSource, while limiting the maximum number of concurrent subscriptions to these ObservableSources. |
<U,R> Observable<R> | flatMap(Function<? superT,? extendsObservableSource<? extends U>> mapper,BiFunction<? superT,? super U,? extends R> combiner, boolean delayErrors, int maxConcurrency, int bufferSize) Returns an Observable that emits the results of a specified function to the pair of values emitted by the source ObservableSource and a specified collection ObservableSource, while limiting the maximum number of concurrent subscriptions to these ObservableSources. |
<U,R> Observable<R> | flatMap(Function<? superT,? extendsObservableSource<? extends U>> mapper,BiFunction<? superT,? super U,? extends R> combiner, int maxConcurrency) Returns an Observable that emits the results of a specified function to the pair of values emitted by the source ObservableSource and a specified collection ObservableSource, while limiting the maximum number of concurrent subscriptions to these ObservableSources. |
Completable | flatMapCompletable(Function<? superT,? extendsCompletableSource> mapper) Maps each element of the upstream Observable into CompletableSources, subscribes to them and waits until the upstream and all CompletableSources complete. |
Completable | flatMapCompletable(Function<? superT,? extendsCompletableSource> mapper, boolean delayErrors) Maps each element of the upstream Observable into CompletableSources, subscribes to them and waits until the upstream and all CompletableSources complete, optionally delaying all errors. |
<U> Observable<U> | flatMapIterable(Function<? superT,? extendsIterable<? extends U>> mapper) Returns an Observable that merges each item emitted by the source ObservableSource with the values in an Iterable corresponding to that item that is generated by a selector. |
<U,V> Observable<V> | flatMapIterable(Function<? superT,? extendsIterable<? extends U>> mapper,BiFunction<? superT,? super U,? extends V> resultSelector) Returns an Observable that emits the results of applying a function to the pair of values from the source ObservableSource and an Iterable corresponding to that item that is generated by a selector. |
<R> Observable<R> | flatMapMaybe(Function<? superT,? extendsMaybeSource<? extends R>> mapper) Maps each element of the upstream Observable into MaybeSources, subscribes to all of them and merges their onSuccess values, in no particular order, into a single Observable sequence. |
<R> Observable<R> | flatMapMaybe(Function<? superT,? extendsMaybeSource<? extends R>> mapper, boolean delayErrors) Maps each element of the upstream Observable into MaybeSources, subscribes to them and merges their onSuccess values, in no particular order, into a single Observable sequence, optionally delaying all errors. |
<R> Observable<R> | flatMapSingle(Function<? superT,? extendsSingleSource<? extends R>> mapper) Maps each element of the upstream Observable into SingleSources, subscribes to all of them and merges their onSuccess values, in no particular order, into a single Observable sequence. |
<R> Observable<R> | flatMapSingle(Function<? superT,? extendsSingleSource<? extends R>> mapper, boolean delayErrors) Maps each element of the upstream Observable into SingleSources, subscribes to them and merges their onSuccess values, in no particular order, into a single Observable sequence, optionally delaying all errors. |
Disposable | forEach(Consumer<? superT> onNext) Subscribes to the ObservableSource and receives notifications for each element. |
Disposable | forEachWhile(Predicate<? superT> onNext) Subscribes to the ObservableSource and receives notifications for each element until the onNext Predicate returns false. |
Disposable | forEachWhile(Predicate<? superT> onNext,Consumer<? superThrowable> onError) Subscribes to the ObservableSource and receives notifications for each element and error events until the onNext Predicate returns false. |
Disposable | forEachWhile(Predicate<? superT> onNext,Consumer<? superThrowable> onError,Action onComplete) Subscribes to the ObservableSource and receives notifications for each element and the terminal events until the onNext Predicate returns false. |
static <T> Observable<T> | fromArray(T... items) Converts an Array into an ObservableSource that emits the items in the Array. |
static <T> Observable<T> | fromCallable(Callable<? extends T> supplier) Returns an Observable that, when an observer subscribes to it, invokes a function you specify and then emits the value returned from that function. |
static <T> Observable<T> | fromFuture(Future<? extends T> future) Converts a Future into an ObservableSource. |
static <T> Observable<T> | fromFuture(Future<? extends T> future, long timeout,TimeUnit unit) Converts a Future into an ObservableSource, with a timeout on the Future. |
static <T> Observable<T> | fromFuture(Future<? extends T> future, long timeout,TimeUnit unit,Scheduler scheduler) Converts a Future into an ObservableSource, with a timeout on the Future. |
static <T> Observable<T> | fromFuture(Future<? extends T> future,Scheduler scheduler) |
static <T> Observable<T> | fromIterable(Iterable<? extends T> source) Converts an Iterable sequence into an ObservableSource that emits the items in the sequence. |
static <T> Observable<T> | fromPublisher(Publisher<? extends T> publisher) Converts an arbitrary Reactive Streams Publisher into an Observable. |
static <T,S> Observable<T> | generate(Callable<S> initialState,BiConsumer<S,Emitter<T>> generator) Returns a cold, synchronous and stateful generator of values. |
static <T,S> Observable<T> | generate(Callable<S> initialState,BiConsumer<S,Emitter<T>> generator,Consumer<? super S> disposeState) Returns a cold, synchronous and stateful generator of values. |
static <T,S> Observable<T> | generate(Callable<S> initialState,BiFunction<S,Emitter<T>,S> generator) Returns a cold, synchronous and stateful generator of values. |
static <T,S> Observable<T> | generate(Callable<S> initialState,BiFunction<S,Emitter<T>,S> generator,Consumer<? super S> disposeState) Returns a cold, synchronous and stateful generator of values. |
static <T> Observable<T> | generate(Consumer<Emitter<T>> generator) Returns a cold, synchronous and stateless generator of values. |
<K> Observable<GroupedObservable<K,T>> | groupBy(Function<? superT,? extends K> keySelector) Groups the items emitted by an ObservableSource according to a specified criterion, and emits these grouped items asGroupedObservable s. |
<K> Observable<GroupedObservable<K,T>> | groupBy(Function<? superT,? extends K> keySelector, boolean delayError) Groups the items emitted by an ObservableSource according to a specified criterion, and emits these grouped items asGroupedObservable s. |
<K,V> Observable<GroupedObservable<K,V>> | groupBy(Function<? superT,? extends K> keySelector,Function<? superT,? extends V> valueSelector) Groups the items emitted by an ObservableSource according to a specified criterion, and emits these grouped items asGroupedObservable s. |
<K,V> Observable<GroupedObservable<K,V>> | groupBy(Function<? superT,? extends K> keySelector,Function<? superT,? extends V> valueSelector, boolean delayError) Groups the items emitted by an ObservableSource according to a specified criterion, and emits these grouped items asGroupedObservable s. |
<K,V> Observable<GroupedObservable<K,V>> | groupBy(Function<? superT,? extends K> keySelector,Function<? superT,? extends V> valueSelector, boolean delayError, int bufferSize) Groups the items emitted by an ObservableSource according to a specified criterion, and emits these grouped items asGroupedObservable s. |
<TRight,TLeftEnd,TRightEnd,R> | groupJoin(ObservableSource<? extends TRight> other,Function<? superT,? extendsObservableSource<TLeftEnd>> leftEnd,Function<? super TRight,? extendsObservableSource<TRightEnd>> rightEnd,BiFunction<? superT,? superObservable<TRight>,? extends R> resultSelector) Returns an Observable that correlates two ObservableSources when they overlap in time and groups the results. |
Observable<T> | hide() Hides the identity of this Observable and its Disposable. |
Completable | ignoreElements() Ignores all items emitted by the source ObservableSource and only calls onComplete oronError . |
staticObservable<Long> | interval(long initialDelay, long period,TimeUnit unit) Returns an Observable that emits a 0L after theinitialDelay and ever increasing numbers after eachperiod of time thereafter. |
staticObservable<Long> | interval(long initialDelay, long period,TimeUnit unit,Scheduler scheduler) Returns an Observable that emits a 0L after theinitialDelay and ever increasing numbers after eachperiod of time thereafter, on a specifiedScheduler . |
staticObservable<Long> | interval(long period,TimeUnit unit) Returns an Observable that emits a sequential number every specified interval of time. |
staticObservable<Long> | interval(long period,TimeUnit unit,Scheduler scheduler) Returns an Observable that emits a sequential number every specified interval of time, on a specified Scheduler. |
staticObservable<Long> | intervalRange(long start, long count, long initialDelay, long period,TimeUnit unit) Signals a range of long values, the first after some initial delay and the rest periodically after. |
staticObservable<Long> | intervalRange(long start, long count, long initialDelay, long period,TimeUnit unit,Scheduler scheduler) Signals a range of long values, the first after some initial delay and the rest periodically after. |
Single<Boolean> | isEmpty() Returns a Single that emits true if the source ObservableSource is empty, otherwisefalse . |
<TRight,TLeftEnd,TRightEnd,R> | join(ObservableSource<? extends TRight> other,Function<? superT,? extendsObservableSource<TLeftEnd>> leftEnd,Function<? super TRight,? extendsObservableSource<TRightEnd>> rightEnd,BiFunction<? superT,? super TRight,? extends R> resultSelector) Correlates the items emitted by two ObservableSources based on overlapping durations. |
static <T> Observable<T> | just(T item) Returns an Observable that signals the given (constant reference) item and then completes. |
static <T> Observable<T> | just(T item1, T item2) Converts two items into an ObservableSource that emits those items. |
static <T> Observable<T> | just(T item1, T item2, T item3) Converts three items into an ObservableSource that emits those items. |
static <T> Observable<T> | just(T item1, T item2, T item3, T item4) Converts four items into an ObservableSource that emits those items. |
static <T> Observable<T> | just(T item1, T item2, T item3, T item4, T item5) Converts five items into an ObservableSource that emits those items. |
static <T> Observable<T> | just(T item1, T item2, T item3, T item4, T item5, T item6) Converts six items into an ObservableSource that emits those items. |
static <T> Observable<T> | just(T item1, T item2, T item3, T item4, T item5, T item6, T item7) Converts seven items into an ObservableSource that emits those items. |
static <T> Observable<T> | just(T item1, T item2, T item3, T item4, T item5, T item6, T item7, T item8) Converts eight items into an ObservableSource that emits those items. |
static <T> Observable<T> | just(T item1, T item2, T item3, T item4, T item5, T item6, T item7, T item8, T item9) Converts nine items into an ObservableSource that emits those items. |
static <T> Observable<T> | just(T item1, T item2, T item3, T item4, T item5, T item6, T item7, T item8, T item9, T item10) Converts ten items into an ObservableSource that emits those items. |
Single<T> | last(T defaultItem) Returns a Single that emits only the last item emitted by this Observable, or a default item if this Observable completes without emitting any items. |
Maybe<T> | lastElement() Returns a Maybe that emits the last item emitted by this Observable or completes if this Observable is empty. |
Single<T> | lastOrError() Returns a Single that emits only the last item emitted by this Observable or signals a NoSuchElementException if this Observable is empty. |
<R> Observable<R> | lift(ObservableOperator<? extends R,? superT> lifter) This method requires advanced knowledge about building operators, please consider other standard composition methods first; Returns an Observable 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. |
<R> Observable<R> | map(Function<? superT,? extends R> mapper) Returns an Observable that applies a specified function to each item emitted by the source ObservableSource and emits the results of these function applications. |
Observable<Notification<T>> | materialize() Returns an Observable that represents all of the emissionsand notifications from the source ObservableSource into emissions marked with their original types within Notification objects. |
static <T> Observable<T> | merge(Iterable<? extendsObservableSource<? extends T>> sources) Flattens an Iterable of ObservableSources into one ObservableSource, without any transformation. |
static <T> Observable<T> | merge(Iterable<? extendsObservableSource<? extends T>> sources, int maxConcurrency) Flattens an Iterable of ObservableSources into one ObservableSource, without any transformation, while limiting the number of concurrent subscriptions to these ObservableSources. |
static <T> Observable<T> | merge(Iterable<? extendsObservableSource<? extends T>> sources, int maxConcurrency, int bufferSize) Flattens an Iterable of ObservableSources into one ObservableSource, without any transformation, while limiting the number of concurrent subscriptions to these ObservableSources. |
static <T> Observable<T> | merge(ObservableSource<? extendsObservableSource<? extends T>> sources) Flattens an ObservableSource that emits ObservableSources into a single ObservableSource that emits the items emitted by those ObservableSources, without any transformation. |
static <T> Observable<T> | merge(ObservableSource<? extendsObservableSource<? extends T>> sources, int maxConcurrency) Flattens an ObservableSource that emits ObservableSources into a single ObservableSource that emits the items emitted by those ObservableSources, without any transformation, while limiting the maximum number of concurrent subscriptions to these ObservableSources. |
static <T> Observable<T> | merge(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2) Flattens two ObservableSources into a single ObservableSource, without any transformation. |
static <T> Observable<T> | merge(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2,ObservableSource<? extends T> source3) Flattens three ObservableSources into a single ObservableSource, without any transformation. |
static <T> Observable<T> | merge(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2,ObservableSource<? extends T> source3,ObservableSource<? extends T> source4) Flattens four ObservableSources into a single ObservableSource, without any transformation. |
static <T> Observable<T> | mergeArray(int maxConcurrency, int bufferSize,ObservableSource<? extends T>... sources) Flattens an Iterable of ObservableSources into one ObservableSource, without any transformation, while limiting the number of concurrent subscriptions to these ObservableSources. |
static <T> Observable<T> | mergeArray(ObservableSource<? extends T>... sources) Flattens an Array of ObservableSources into one ObservableSource, without any transformation. |
static <T> Observable<T> | mergeArrayDelayError(int maxConcurrency, int bufferSize,ObservableSource<? extends T>... sources) Flattens an array of ObservableSources into one ObservableSource, in a way that allows an Observer to receive all successfully emitted items from each of the source ObservableSources without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to these ObservableSources. |
static <T> Observable<T> | mergeArrayDelayError(ObservableSource<? extends T>... sources) Flattens an Iterable of ObservableSources into one ObservableSource, in a way that allows an Observer to receive all successfully emitted items from each of the source ObservableSources without being interrupted by an error notification from one of them. |
static <T> Observable<T> | mergeDelayError(Iterable<? extendsObservableSource<? extends T>> sources) Flattens an Iterable of ObservableSources into one ObservableSource, in a way that allows an Observer to receive all successfully emitted items from each of the source ObservableSources without being interrupted by an error notification from one of them. |
static <T> Observable<T> | mergeDelayError(Iterable<? extendsObservableSource<? extends T>> sources, int maxConcurrency) Flattens an Iterable of ObservableSources into one ObservableSource, in a way that allows an Observer to receive all successfully emitted items from each of the source ObservableSources without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to these ObservableSources. |
static <T> Observable<T> | mergeDelayError(Iterable<? extendsObservableSource<? extends T>> sources, int maxConcurrency, int bufferSize) Flattens an Iterable of ObservableSources into one ObservableSource, in a way that allows an Observer to receive all successfully emitted items from each of the source ObservableSources without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to these ObservableSources. |
static <T> Observable<T> | mergeDelayError(ObservableSource<? extendsObservableSource<? extends T>> sources) Flattens an ObservableSource that emits ObservableSources into one ObservableSource, in a way that allows an Observer to receive all successfully emitted items from all of the source ObservableSources without being interrupted by an error notification from one of them. |
static <T> Observable<T> | mergeDelayError(ObservableSource<? extendsObservableSource<? extends T>> sources, int maxConcurrency) Flattens an ObservableSource that emits ObservableSources into one ObservableSource, in a way that allows an Observer to receive all successfully emitted items from all of the source ObservableSources without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to these ObservableSources. |
static <T> Observable<T> | mergeDelayError(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2) Flattens two ObservableSources into one ObservableSource, in a way that allows an Observer to receive all successfully emitted items from each of the source ObservableSources without being interrupted by an error notification from one of them. |
static <T> Observable<T> | mergeDelayError(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2,ObservableSource<? extends T> source3) Flattens three ObservableSources into one ObservableSource, in a way that allows an Observer to receive all successfully emitted items from all of the source ObservableSources without being interrupted by an error notification from one of them. |
static <T> Observable<T> | mergeDelayError(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2,ObservableSource<? extends T> source3,ObservableSource<? extends T> source4) Flattens four ObservableSources into one ObservableSource, in a way that allows an Observer to receive all successfully emitted items from all of the source ObservableSources without being interrupted by an error notification from one of them. |
Observable<T> | mergeWith(CompletableSource other) Relays the items of this Observable and completes only when the other CompletableSource completes as well. |
Observable<T> | mergeWith(MaybeSource<? extendsT> other) Merges the sequence of items of this Observable with the success value of the other MaybeSource or waits both to complete normally if the MaybeSource is empty. |
Observable<T> | mergeWith(ObservableSource<? extendsT> other) Flattens this and another ObservableSource into a single ObservableSource, without any transformation. |
Observable<T> | mergeWith(SingleSource<? extendsT> other) Merges the sequence of items of this Observable with the success value of the other SingleSource. |
static <T> Observable<T> | never() Returns an Observable that never sends any items or notifications to an Observer . |
Observable<T> | observeOn(Scheduler scheduler) Modifies an ObservableSource to perform its emissions and notifications on a specified Scheduler , asynchronously with an unbounded buffer withFlowable.bufferSize() "island size". |
Observable<T> | observeOn(Scheduler scheduler, boolean delayError) Modifies an ObservableSource to perform its emissions and notifications on a specified Scheduler , asynchronously with an unbounded buffer withFlowable.bufferSize() "island size" and optionally delays onError notifications. |
Observable<T> | observeOn(Scheduler scheduler, boolean delayError, int bufferSize) Modifies an ObservableSource to perform its emissions and notifications on a specified Scheduler , asynchronously with an unbounded buffer of configurable "island size" and optionally delays onError notifications. |
<U> Observable<U> | ofType(Class<U> clazz) Filters the items emitted by an ObservableSource, only emitting those of the specified type. |
Observable<T> | onErrorResumeNext(Function<? superThrowable,? extendsObservableSource<? extendsT>> resumeFunction) Instructs an ObservableSource to pass control to another ObservableSource rather than invoking onError if it encounters an error. |
Observable<T> | onErrorResumeNext(ObservableSource<? extendsT> next) Instructs an ObservableSource to pass control to another ObservableSource rather than invoking onError if it encounters an error. |
Observable<T> | onErrorReturn(Function<? superThrowable,? extendsT> valueSupplier) Instructs an ObservableSource to emit an item (returned by a specified function) rather than invoking onError if it encounters an error. |
Observable<T> | onErrorReturnItem(T item) Instructs an ObservableSource to emit an item (returned by a specified function) rather than invoking onError if it encounters an error. |
Observable<T> | onExceptionResumeNext(ObservableSource<? extendsT> next) |
Observable<T> | onTerminateDetach() Nulls out references to the upstream producer and downstream Observer if the sequence is terminated or downstream calls dispose(). |
ConnectableObservable<T> | publish() Returns a ConnectableObservable , which is a variety of ObservableSource that waits until itsconnect method is called before it begins emitting items to thoseObserver s that have subscribed to it. |
<R> Observable<R> | publish(Function<? superObservable<T>,? extendsObservableSource<R>> selector) Returns an Observable that emits the results of invoking a specified selector on items emitted by a ConnectableObservable that shares a single subscription to the underlying sequence. |
staticObservable<Integer> | range(int start, int count) Returns an Observable that emits a sequence of Integers within a specified range. |
staticObservable<Long> | rangeLong(long start, long count) Returns an Observable that emits a sequence of Longs within a specified range. |
Maybe<T> | reduce(BiFunction<T,T,T> reducer) Returns a Maybe that applies a specified accumulator function to the first item emitted by a source ObservableSource, then feeds the result of that function along with the second item emitted by the source ObservableSource into the same function, and so on until all items have been emitted by the finite source ObservableSource, and emits the final result from the final call to your function as its sole item. |
<R> Single<R> | reduce(R seed,BiFunction<R,? superT,R> reducer) Returns a Single that applies a specified accumulator function to the first item emitted by a source ObservableSource and a specified seed value, then feeds the result of that function along with the second item emitted by an ObservableSource into the same function, and so on until all items have been emitted by the finite source ObservableSource, emitting the final result from the final call to your function as its sole item. |
<R> Single<R> | reduceWith(Callable<R> seedSupplier,BiFunction<R,? superT,R> reducer) Returns a Single that applies a specified accumulator function to the first item emitted by a source ObservableSource and a seed value derived from calling a specified seedSupplier, then feeds the result of that function along with the second item emitted by an ObservableSource into the same function, and so on until all items have been emitted by the finite source ObservableSource, emitting the final result from the final call to your function as its sole item. |
Observable<T> | repeat() Returns an Observable that repeats the sequence of items emitted by the source ObservableSource indefinitely. |
Observable<T> | repeat(long times) Returns an Observable that repeats the sequence of items emitted by the source ObservableSource at most count times. |
Observable<T> | repeatUntil(BooleanSupplier stop) Returns an Observable that repeats the sequence of items emitted by the source ObservableSource until the provided stop function returns true. |
Observable<T> | repeatWhen(Function<? superObservable<Object>,? extendsObservableSource<?>> handler) Returns an Observable that emits the same values as the source ObservableSource with the exception of an onComplete . |
ConnectableObservable<T> | replay() Returns a ConnectableObservable that shares a single subscription to the underlying ObservableSource that will replay all of its items and notifications to any futureObserver . |
<R> Observable<R> | replay(Function<? superObservable<T>,? extendsObservableSource<R>> selector) Returns an Observable that emits items that are the results of invoking a specified selector on the items emitted by a ConnectableObservable that shares a single subscription to the source ObservableSource. |
<R> Observable<R> | replay(Function<? superObservable<T>,? extendsObservableSource<R>> selector, int bufferSize) Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a ConnectableObservable that shares a single subscription to the source ObservableSource, replayingbufferSize notifications. |
<R> Observable<R> | replay(Function<? superObservable<T>,? extendsObservableSource<R>> selector, int bufferSize, long time,TimeUnit unit) Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a ConnectableObservable that shares a single subscription to the source ObservableSource, replaying no more thanbufferSize items that were emitted within a specified time window. |
<R> Observable<R> | replay(Function<? superObservable<T>,? extendsObservableSource<R>> selector, int bufferSize, long time,TimeUnit unit,Scheduler scheduler) Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a ConnectableObservable that shares a single subscription to the source ObservableSource, replaying no more thanbufferSize items that were emitted within a specified time window. |
<R> Observable<R> | replay(Function<? superObservable<T>,? extendsObservableSource<R>> selector, int bufferSize,Scheduler scheduler) Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a ConnectableObservable that shares a single subscription to the source ObservableSource, replaying a maximum ofbufferSize items. |
<R> Observable<R> | replay(Function<? superObservable<T>,? extendsObservableSource<R>> selector, long time,TimeUnit unit) Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a ConnectableObservable that shares a single subscription to the source ObservableSource, replaying all items that were emitted within a specified time window. |
<R> Observable<R> | replay(Function<? superObservable<T>,? extendsObservableSource<R>> selector, long time,TimeUnit unit,Scheduler scheduler) Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a ConnectableObservable that shares a single subscription to the source ObservableSource, replaying all items that were emitted within a specified time window. |
<R> Observable<R> | replay(Function<? superObservable<T>,? extendsObservableSource<R>> selector,Scheduler scheduler) Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a ConnectableObservable that shares a single subscription to the source ObservableSource. |
ConnectableObservable<T> | replay(int bufferSize) Returns a ConnectableObservable that shares a single subscription to the source ObservableSource that replays at mostbufferSize items emitted by that ObservableSource. |
ConnectableObservable<T> | replay(int bufferSize, long time,TimeUnit unit) Returns a ConnectableObservable that shares a single subscription to the source ObservableSource and replays at mostbufferSize items that were emitted during a specified time window. |
ConnectableObservable<T> | replay(int bufferSize, long time,TimeUnit unit,Scheduler scheduler) Returns a ConnectableObservable that shares a single subscription to the source ObservableSource and that replays a maximum ofbufferSize items that are emitted within a specified time window. |
ConnectableObservable<T> | replay(int bufferSize,Scheduler scheduler) Returns a ConnectableObservable that shares a single subscription to the source ObservableSource and replays at mostbufferSize items emitted by that ObservableSource. |
ConnectableObservable<T> | replay(long time,TimeUnit unit) Returns a ConnectableObservable that shares a single subscription to the source ObservableSource and replays all items emitted by that ObservableSource within a specified time window. |
ConnectableObservable<T> | replay(long time,TimeUnit unit,Scheduler scheduler) Returns a ConnectableObservable that shares a single subscription to the source ObservableSource and replays all items emitted by that ObservableSource within a specified time window. |
ConnectableObservable<T> | replay(Scheduler scheduler) Returns a ConnectableObservable that shares a single subscription to the source ObservableSource that will replay all of its items and notifications to any futureObserver on the givenScheduler . |
Observable<T> | retry() Returns an Observable that mirrors the source ObservableSource, resubscribing to it if it calls onError (infinite retry count). |
Observable<T> | retry(BiPredicate<? superInteger,? superThrowable> predicate) Returns an Observable that mirrors the source ObservableSource, resubscribing to it if it calls onError and the predicate returns true for that specific exception and retry count. |
Observable<T> | retry(long times) Returns an Observable that mirrors the source ObservableSource, resubscribing to it if it calls onError up to a specified number of retries. |
Observable<T> | retry(long times,Predicate<? superThrowable> predicate) Retries at most times or until the predicate returns false, whichever happens first. |
Observable<T> | retry(Predicate<? superThrowable> predicate) Retries the current Observable if the predicate returns true. |
Observable<T> | retryUntil(BooleanSupplier stop) Retries until the given stop function returns true. |
Observable<T> | retryWhen(Function<? superObservable<Throwable>,? extendsObservableSource<?>> handler) Returns an Observable that emits the same values as the source ObservableSource with the exception of an onError . |
void | safeSubscribe(Observer<? superT> observer) Subscribes to the current Observable and wraps the given Observer into a SafeObserver (if not already a SafeObserver) that deals with exceptions thrown by a misbehaving Observer (that doesn't follow the Reactive Streams specification). |
Observable<T> | sample(long period,TimeUnit unit) Returns an Observable that emits the most recently emitted item (if any) emitted by the source ObservableSource within periodic time intervals. |
Observable<T> | sample(long period,TimeUnit unit, boolean emitLast) Returns an Observable that emits the most recently emitted item (if any) emitted by the source ObservableSource within periodic time intervals and optionally emit the very last upstream item when the upstream completes. |
Observable<T> | sample(long period,TimeUnit unit,Scheduler scheduler) Returns an Observable that emits the most recently emitted item (if any) emitted by the source ObservableSource within periodic time intervals, where the intervals are defined on a particular Scheduler. |
Observable<T> | sample(long period,TimeUnit unit,Scheduler scheduler, boolean emitLast) Returns an Observable that emits the most recently emitted item (if any) emitted by the source ObservableSource within periodic time intervals, where the intervals are defined on a particular Scheduler and optionally emit the very last upstream item when the upstream completes. |
<U> Observable<T> | sample(ObservableSource<U> sampler) Returns an Observable that, when the specified sampler ObservableSource emits an item or completes, emits the most recently emitted item (if any) emitted by the source ObservableSource since the previous emission from thesampler ObservableSource. |
<U> Observable<T> | sample(ObservableSource<U> sampler, boolean emitLast) Returns an Observable that, when the specified sampler ObservableSource emits an item or completes, emits the most recently emitted item (if any) emitted by the source ObservableSource since the previous emission from thesampler ObservableSource and optionally emit the very last upstream item when the upstream or other ObservableSource complete. |
Observable<T> | scan(BiFunction<T,T,T> accumulator) Returns an Observable that applies a specified accumulator function to the first item emitted by a source ObservableSource, then feeds the result of that function along with the second item emitted by the source ObservableSource into the same function, and so on until all items have been emitted by the source ObservableSource, emitting the result of each of these iterations. |
<R> Observable<R> | scan(R initialValue,BiFunction<R,? superT,R> accumulator) Returns an Observable that applies a specified accumulator function to the first item emitted by a source ObservableSource and a seed value, then feeds the result of that function along with the second item emitted by the source ObservableSource into the same function, and so on until all items have been emitted by the source ObservableSource, emitting the result of each of these iterations. |
<R> Observable<R> | scanWith(Callable<R> seedSupplier,BiFunction<R,? superT,R> accumulator) Returns an Observable that applies a specified accumulator function to the first item emitted by a source ObservableSource and a seed value, then feeds the result of that function along with the second item emitted by the source ObservableSource into the same function, and so on until all items have been emitted by the source ObservableSource, emitting the result of each of these iterations. |
static <T> Single<Boolean> | sequenceEqual(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2) Returns a Single that emits a Boolean value that indicates whether two ObservableSource sequences are the same by comparing the items emitted by each ObservableSource pairwise. |
static <T> Single<Boolean> | sequenceEqual(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2,BiPredicate<? super T,? super T> isEqual) Returns a Single that emits a Boolean value that indicates whether two ObservableSource sequences are the same by comparing the items emitted by each ObservableSource pairwise based on the results of a specified equality function. |
static <T> Single<Boolean> | sequenceEqual(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2,BiPredicate<? super T,? super T> isEqual, int bufferSize) Returns a Single that emits a Boolean value that indicates whether two ObservableSource sequences are the same by comparing the items emitted by each ObservableSource pairwise based on the results of a specified equality function. |
static <T> Single<Boolean> | sequenceEqual(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2, int bufferSize) Returns a Single that emits a Boolean value that indicates whether two ObservableSource sequences are the same by comparing the items emitted by each ObservableSource pairwise. |
Observable<T> | serialize() Forces an ObservableSource's emissions and notifications to be serialized and for it to obeythe ObservableSource contract in other ways. |
Observable<T> | share() Returns a new ObservableSource that multicasts (and shares a single subscription to) the originalObservableSource . |
Single<T> | single(T defaultItem) Returns a Single that emits the single item emitted by this Observable, if this Observable emits only a single item, or a default item if the source ObservableSource emits no items. |
Maybe<T> | singleElement() Returns a Maybe that completes if this Observable is empty or emits the single item emitted by this Observable, or signals an IllegalArgumentException if this Observable emits more than one item. |
Single<T> | singleOrError() Returns a Single that emits the single item emitted by this Observable if this Observable emits only a single item, otherwise if this Observable completes without emitting any items or emits more than one item a NoSuchElementException orIllegalArgumentException will be signalled respectively. |
Observable<T> | skip(long count) Returns an Observable that skips the first count items emitted by the source ObservableSource and emits the remainder. |
Observable<T> | skip(long time,TimeUnit unit) Returns an Observable that skips values emitted by the source ObservableSource before a specified time window elapses. |
Observable<T> | skip(long time,TimeUnit unit,Scheduler scheduler) Returns an Observable that skips values emitted by the source ObservableSource before a specified time window on a specified Scheduler elapses. |
Observable<T> | skipLast(int count) Returns an Observable that drops a specified number of items from the end of the sequence emitted by the source ObservableSource. |
Observable<T> | skipLast(long time,TimeUnit unit) Returns an Observable that drops items emitted by the source ObservableSource during a specified time window before the source completes. |
Observable<T> | skipLast(long time,TimeUnit unit, boolean delayError) Returns an Observable that drops items emitted by the source ObservableSource during a specified time window before the source completes. |
Observable<T> | skipLast(long time,TimeUnit unit,Scheduler scheduler) Returns an Observable that drops items emitted by the source ObservableSource during a specified time window (defined on a specified scheduler) before the source completes. |
Observable<T> | skipLast(long time,TimeUnit unit,Scheduler scheduler, boolean delayError) Returns an Observable that drops items emitted by the source ObservableSource during a specified time window (defined on a specified scheduler) before the source completes. |
Observable<T> | skipLast(long time,TimeUnit unit,Scheduler scheduler, boolean delayError, int bufferSize) Returns an Observable that drops items emitted by the source ObservableSource during a specified time window (defined on a specified scheduler) before the source completes. |
<U> Observable<T> | skipUntil(ObservableSource<U> other) Returns an Observable that skips items emitted by the source ObservableSource until a second ObservableSource emits an item. |
Observable<T> | skipWhile(Predicate<? superT> predicate) Returns an Observable that skips all items emitted by the source ObservableSource as long as a specified condition holds true, but emits all further source items as soon as the condition becomes false. |
Observable<T> | sorted() Returns an Observable that emits the events emitted by source ObservableSource, in a sorted order. |
Observable<T> | sorted(Comparator<? superT> sortFunction) Returns an Observable that emits the events emitted by source ObservableSource, in a sorted order based on a specified comparison function. |
Observable<T> | startWith(Iterable<? extendsT> items) Returns an Observable that emits the items in a specified Iterable before it begins to emit items emitted by the source ObservableSource. |
Observable<T> | startWith(ObservableSource<? extendsT> other) Returns an Observable that emits the items in a specified ObservableSource before it begins to emit items emitted by the source ObservableSource. |
Observable<T> | startWith(T item) Returns an Observable that emits a specified item before it begins to emit items emitted by the source ObservableSource. |
Observable<T> | startWithArray(T... items) Returns an Observable that emits the specified items before it begins to emit items emitted by the source ObservableSource. |
Disposable | subscribe() Subscribes to an ObservableSource and ignores onNext andonComplete emissions. |
Disposable | subscribe(Consumer<? superT> onNext) Subscribes to an ObservableSource and provides a callback to handle the items it emits. |
Disposable | subscribe(Consumer<? superT> onNext,Consumer<? superThrowable> onError) Subscribes to an ObservableSource and provides callbacks to handle the items it emits and any error notification it issues. |
Disposable | subscribe(Consumer<? superT> onNext,Consumer<? superThrowable> onError,Action onComplete) Subscribes to an ObservableSource and provides callbacks to handle the items it emits and any error or completion notification it issues. |
Disposable | subscribe(Consumer<? superT> onNext,Consumer<? superThrowable> onError,Action onComplete,Consumer<? superDisposable> onSubscribe) Subscribes to an ObservableSource and provides callbacks to handle the items it emits and any error or completion notification it issues. |
void | subscribe(Observer<? superT> observer) Subscribes the given Observer to this ObservableSource instance. |
protected abstract void | subscribeActual(Observer<? superT> observer) Operator implementations (both source and intermediate) should implement this method that performs the necessary business logic and handles the incoming Observer s. |
Observable<T> | subscribeOn(Scheduler scheduler) Asynchronously subscribes Observers to this ObservableSource on the specified Scheduler . |
<E extendsObserver<? superT>> | subscribeWith(E observer) Subscribes a given Observer (subclass) to this Observable and returns the given Observer as is. |
Observable<T> | switchIfEmpty(ObservableSource<? extendsT> other) Returns an Observable that emits the items emitted by the source ObservableSource or the items of an alternate ObservableSource if the source ObservableSource is empty. |
<R> Observable<R> | switchMap(Function<? superT,? extendsObservableSource<? extends R>> mapper) Returns a new ObservableSource by applying a function that you supply to each item emitted by the source ObservableSource that returns an ObservableSource, and then emitting the items emitted by the most recently emitted of these ObservableSources. |
<R> Observable<R> | switchMap(Function<? superT,? extendsObservableSource<? extends R>> mapper, int bufferSize) Returns a new ObservableSource by applying a function that you supply to each item emitted by the source ObservableSource that returns an ObservableSource, and then emitting the items emitted by the most recently emitted of these ObservableSources. |
Completable | switchMapCompletable(Function<? superT,? extendsCompletableSource> mapper) Maps the upstream values into CompletableSource s, subscribes to the newer one while disposing the subscription to the previousCompletableSource , thus keeping at most one activeCompletableSource running. |
Completable | switchMapCompletableDelayError(Function<? superT,? extendsCompletableSource> mapper) Maps the upstream values into CompletableSource 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. |
<R> Observable<R> | switchMapDelayError(Function<? superT,? extendsObservableSource<? extends R>> mapper) Returns a new ObservableSource by applying a function that you supply to each item emitted by the source ObservableSource that returns an ObservableSource, and then emitting the items emitted by the most recently emitted of these ObservableSources and delays any error until all ObservableSources terminate. |
<R> Observable<R> | switchMapDelayError(Function<? superT,? extendsObservableSource<? extends R>> mapper, int bufferSize) Returns a new ObservableSource by applying a function that you supply to each item emitted by the source ObservableSource that returns an ObservableSource, and then emitting the items emitted by the most recently emitted of these ObservableSources and delays any error until all ObservableSources terminate. |
<R> Observable<R> | switchMapMaybe(Function<? superT,? extendsMaybeSource<? extends R>> mapper) Maps the upstream items into MaybeSource 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 thisObservable or any of the active innerMaybeSource s fail. |
<R> Observable<R> | switchMapMaybeDelayError(Function<? superT,? extendsMaybeSource<? extends R>> mapper) Maps the upstream items into MaybeSource 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 thisObservable or the innerMaybeSource s until all terminate. |
<R> Observable<R> | switchMapSingle(Function<? superT,? extendsSingleSource<? extends R>> mapper) Returns a new ObservableSource by applying a function that you supply to each item emitted by the source ObservableSource that returns a SingleSource, and then emitting the item emitted by the most recently emitted of these SingleSources. |
<R> Observable<R> | switchMapSingleDelayError(Function<? superT,? extendsSingleSource<? extends R>> mapper) Returns a new ObservableSource by applying a function that you supply to each item emitted by the source ObservableSource that returns a SingleSource, and then emitting the item emitted by the most recently emitted of these SingleSources and delays any error until all SingleSources terminate. |
static <T> Observable<T> | switchOnNext(ObservableSource<? extendsObservableSource<? extends T>> sources) Converts an ObservableSource that emits ObservableSources into an ObservableSource that emits the items emitted by the most recently emitted of those ObservableSources. |
static <T> Observable<T> | switchOnNext(ObservableSource<? extendsObservableSource<? extends T>> sources, int bufferSize) Converts an ObservableSource that emits ObservableSources into an ObservableSource that emits the items emitted by the most recently emitted of those ObservableSources. |
static <T> Observable<T> | switchOnNextDelayError(ObservableSource<? extendsObservableSource<? extends T>> sources) Converts an ObservableSource that emits ObservableSources into an ObservableSource that emits the items emitted by the most recently emitted of those ObservableSources and delays any exception until all ObservableSources terminate. |
static <T> Observable<T> | switchOnNextDelayError(ObservableSource<? extendsObservableSource<? extends T>> sources, int prefetch) Converts an ObservableSource that emits ObservableSources into an ObservableSource that emits the items emitted by the most recently emitted of those ObservableSources and delays any exception until all ObservableSources terminate. |
Observable<T> | take(long count) Returns an Observable that emits only the first count items emitted by the source ObservableSource. |
Observable<T> | take(long time,TimeUnit unit) Returns an Observable that emits those items emitted by source ObservableSource before a specified time runs out. |
Observable<T> | take(long time,TimeUnit unit,Scheduler scheduler) Returns an Observable that emits those items emitted by source ObservableSource before a specified time (on a specified Scheduler) runs out. |
Observable<T> | takeLast(int count) Returns an Observable that emits at most the last count items emitted by the source ObservableSource. |
Observable<T> | takeLast(long count, long time,TimeUnit unit) Returns an Observable that emits at most a specified number of items from the source ObservableSource that were emitted in a specified window of time before the ObservableSource completed. |
Observable<T> | takeLast(long count, long time,TimeUnit unit,Scheduler scheduler) Returns an Observable that emits at most a specified number of items from the source ObservableSource that were emitted in a specified window of time before the ObservableSource completed, where the timing information is provided by a given Scheduler. |
Observable<T> | takeLast(long count, long time,TimeUnit unit,Scheduler scheduler, boolean delayError, int bufferSize) Returns an Observable that emits at most a specified number of items from the source ObservableSource that were emitted in a specified window of time before the ObservableSource completed, where the timing information is provided by a given Scheduler. |
Observable<T> | takeLast(long time,TimeUnit unit) Returns an Observable that emits the items from the source ObservableSource that were emitted in a specified window of time before the ObservableSource completed. |
Observable<T> | takeLast(long time,TimeUnit unit, boolean delayError) Returns an Observable that emits the items from the source ObservableSource that were emitted in a specified window of time before the ObservableSource completed. |
Observable<T> | takeLast(long time,TimeUnit unit,Scheduler scheduler) Returns an Observable that emits the items from the source ObservableSource that were emitted in a specified window of time before the ObservableSource completed, where the timing information is provided by a specified Scheduler. |
Observable<T> | takeLast(long time,TimeUnit unit,Scheduler scheduler, boolean delayError) Returns an Observable that emits the items from the source ObservableSource that were emitted in a specified window of time before the ObservableSource completed, where the timing information is provided by a specified Scheduler. |
Observable<T> | takeLast(long time,TimeUnit unit,Scheduler scheduler, boolean delayError, int bufferSize) Returns an Observable that emits the items from the source ObservableSource that were emitted in a specified window of time before the ObservableSource completed, where the timing information is provided by a specified Scheduler. |
<U> Observable<T> | takeUntil(ObservableSource<U> other) Returns an Observable that emits the items emitted by the source Observable until a second ObservableSource emits an item. |
Observable<T> | takeUntil(Predicate<? superT> stopPredicate) Returns an Observable that emits items emitted by the source Observable, checks the specified predicate for each item, and then completes when the condition is satisfied. |
Observable<T> | takeWhile(Predicate<? superT> predicate) Returns an Observable that emits items emitted by the source ObservableSource so long as each item satisfied a specified condition, and then completes as soon as this condition is not satisfied. |
TestObserver<T> | test() Creates a TestObserver and subscribes it to this Observable. |
TestObserver<T> | test(boolean dispose) Creates a TestObserver, optionally disposes it and then subscribes it to this Observable. |
Observable<T> | throttleFirst(long windowDuration,TimeUnit unit) Returns an Observable that emits only the first item emitted by the source ObservableSource during sequential time windows of a specified duration. |
Observable<T> | throttleFirst(long skipDuration,TimeUnit unit,Scheduler scheduler) Returns an Observable that emits only the first item emitted by the source ObservableSource during sequential time windows of a specified duration, where the windows are managed by a specified Scheduler. |
Observable<T> | throttleLast(long intervalDuration,TimeUnit unit) Returns an Observable that emits only the last item emitted by the source ObservableSource during sequential time windows of a specified duration. |
Observable<T> | throttleLast(long intervalDuration,TimeUnit unit,Scheduler scheduler) Returns an Observable that emits only the last item emitted by the source ObservableSource during sequential time windows of a specified duration, where the duration is governed by a specified Scheduler. |
Observable<T> | throttleLatest(long timeout,TimeUnit unit) Throttles items from the upstream Observable by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them. |
Observable<T> | throttleLatest(long timeout,TimeUnit unit, boolean emitLast) Throttles items from the upstream Observable by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them. |
Observable<T> | throttleLatest(long timeout,TimeUnit unit,Scheduler scheduler) Throttles items from the upstream Observable by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them. |
Observable<T> | throttleLatest(long timeout,TimeUnit unit,Scheduler scheduler, boolean emitLast) Throttles items from the upstream Observable by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them. |
Observable<T> | throttleWithTimeout(long timeout,TimeUnit unit) Returns an Observable that mirrors the source ObservableSource, except that it drops items emitted by the source ObservableSource that are followed by newer items before a timeout value expires. |
Observable<T> | throttleWithTimeout(long timeout,TimeUnit unit,Scheduler scheduler) Returns an Observable that mirrors the source ObservableSource, except that it drops items emitted by the source ObservableSource that are followed by newer items before a timeout value expires on a specified Scheduler. |
Observable<Timed<T>> | timeInterval() Returns an Observable that emits records of the time interval between consecutive items emitted by the source ObservableSource. |
Observable<Timed<T>> | timeInterval(Scheduler scheduler) Returns an Observable that emits records of the time interval between consecutive items emitted by the source ObservableSource, where this interval is computed on a specified Scheduler. |
Observable<Timed<T>> | timeInterval(TimeUnit unit) Returns an Observable that emits records of the time interval between consecutive items emitted by the source ObservableSource. |
Observable<Timed<T>> | timeInterval(TimeUnit unit,Scheduler scheduler) Returns an Observable that emits records of the time interval between consecutive items emitted by the source ObservableSource, where this interval is computed on a specified Scheduler. |
<V> Observable<T> | timeout(Function<? superT,? extendsObservableSource<V>> itemTimeoutIndicator) Returns an Observable that mirrors the source ObservableSource, but notifies observers of a TimeoutException if an item emitted by the source ObservableSource doesn't arrive within a window of time after the emission of the previous item, where that period of time is measured by an ObservableSource that is a function of the previous item. |
<V> Observable<T> | timeout(Function<? superT,? extendsObservableSource<V>> itemTimeoutIndicator,ObservableSource<? extendsT> other) Returns an Observable that mirrors the source ObservableSource, but that switches to a fallback ObservableSource if an item emitted by the source ObservableSource doesn't arrive within a window of time after the emission of the previous item, where that period of time is measured by an ObservableSource that is a function of the previous item. |
Observable<T> | timeout(long timeout,TimeUnit timeUnit) Returns an Observable that mirrors the source ObservableSource but applies a timeout policy for each emitted item. |
Observable<T> | timeout(long timeout,TimeUnit timeUnit,ObservableSource<? extendsT> other) Returns an Observable that mirrors the source ObservableSource but applies a timeout policy for each emitted item. |
Observable<T> | timeout(long timeout,TimeUnit timeUnit,Scheduler scheduler) Returns an Observable that mirrors the source ObservableSource but applies a timeout policy for each emitted item, where this policy is governed on a specified Scheduler. |
Observable<T> | timeout(long timeout,TimeUnit timeUnit,Scheduler scheduler,ObservableSource<? extendsT> other) Returns an Observable that mirrors the source ObservableSource but applies a timeout policy for each emitted item using a specified Scheduler. |
<U,V> Observable<T> | timeout(ObservableSource<U> firstTimeoutIndicator,Function<? superT,? extendsObservableSource<V>> itemTimeoutIndicator) Returns an Observable that mirrors the source ObservableSource, but notifies observers of a TimeoutException if either the first item emitted by the source ObservableSource or any subsequent item doesn't arrive within time windows defined by other ObservableSources. |
<U,V> Observable<T> | timeout(ObservableSource<U> firstTimeoutIndicator,Function<? superT,? extendsObservableSource<V>> itemTimeoutIndicator,ObservableSource<? extendsT> other) Returns an Observable that mirrors the source ObservableSource, but switches to a fallback ObservableSource if either the first item emitted by the source ObservableSource or any subsequent item doesn't arrive within time windows defined by other ObservableSources. |
staticObservable<Long> | timer(long delay,TimeUnit unit) Returns an Observable that emits 0L after a specified delay, and then completes. |
staticObservable<Long> | timer(long delay,TimeUnit unit,Scheduler scheduler) Returns an Observable that emits 0L after a specified delay, on a specified Scheduler, and then completes. |
Observable<Timed<T>> | timestamp() Returns an Observable that emits each item emitted by the source ObservableSource, wrapped in a Timed object. |
Observable<Timed<T>> | timestamp(Scheduler scheduler) Returns an Observable that emits each item emitted by the source ObservableSource, wrapped in a Timed object whose timestamps are provided by a specified Scheduler. |
Observable<Timed<T>> | timestamp(TimeUnit unit) Returns an Observable that emits each item emitted by the source ObservableSource, wrapped in a Timed object. |
Observable<Timed<T>> | timestamp(TimeUnit unit,Scheduler scheduler) Returns an Observable that emits each item emitted by the source ObservableSource, wrapped in a Timed object whose timestamps are provided by a specified Scheduler. |
<R> R | to(Function<? superObservable<T>,R> converter) Calls the specified converter function during assembly time and returns its resulting value. |
Flowable<T> | toFlowable(BackpressureStrategy strategy) Converts the current Observable into a Flowable by applying the specified backpressure strategy. |
Future<T> | toFuture() Returns a Future representing the only value emitted by thisObservable . |
Single<List<T>> | toList() Returns a Single that emits a single item, a list composed of all the items emitted by the finite source ObservableSource. |
<U extendsCollection<? superT>> | toList(Callable<U> collectionSupplier) Returns a Single that emits a single item, a list composed of all the items emitted by the finite source ObservableSource. |
Single<List<T>> | toList(int capacityHint) Returns a Single that emits a single item, a list composed of all the items emitted by the finite source ObservableSource. |
<K> Single<Map<K,T>> | toMap(Function<? superT,? extends K> keySelector) Returns a Single that emits a single HashMap containing all items emitted by the finite source ObservableSource, mapped by the keys returned by a specified keySelector function. |
<K,V> Single<Map<K,V>> | toMap(Function<? superT,? extends K> keySelector,Function<? superT,? extends V> valueSelector) Returns a Single that emits a single HashMap containing values corresponding to items emitted by the finite source ObservableSource, mapped by the keys returned by a specified keySelector function. |
<K,V> Single<Map<K,V>> | toMap(Function<? superT,? extends K> keySelector,Function<? superT,? extends V> valueSelector,Callable<? extendsMap<K,V>> mapSupplier) Returns a Single that emits a single Map, returned by a specified mapFactory function, that contains keys and values extracted from the items emitted by the finite source ObservableSource. |
<K> Single<Map<K,Collection<T>>> | toMultimap(Function<? superT,? extends K> keySelector) Returns a Single that emits a single HashMap that contains an ArrayList of items emitted by the finite source ObservableSource keyed by a specified keySelector function. |
<K,V> Single<Map<K,Collection<V>>> | toMultimap(Function<? superT,? extends K> keySelector,Function<? superT,? extends V> valueSelector) Returns a Single that emits a single HashMap that contains an ArrayList of values extracted by a specified valueSelector function from items emitted by the finite source ObservableSource, keyed by a specifiedkeySelector function. |
<K,V> Single<Map<K,Collection<V>>> | toMultimap(Function<? superT,? extends K> keySelector,Function<? superT,? extends V> valueSelector,Callable<? extendsMap<K,Collection<V>>> mapSupplier,Function<? super K,? extendsCollection<? super V>> collectionFactory) Returns a Single that emits a single Map, returned by a specified mapFactory function, that contains a custom collection of values, extracted by a specifiedvalueSelector function from items emitted by the source ObservableSource, and keyed by thekeySelector function. |
<K,V> Single<Map<K,Collection<V>>> | toMultimap(Function<? superT,? extends K> keySelector,Function<? superT,? extends V> valueSelector,Callable<Map<K,Collection<V>>> mapSupplier) Returns a Single that emits a single Map, returned by a specified mapFactory function, that contains an ArrayList of values, extracted by a specifiedvalueSelector function from items emitted by the finite source ObservableSource and keyed by thekeySelector function. |
Single<List<T>> | toSortedList() Returns a Single that emits a list that contains the items emitted by the finite source ObservableSource, in a sorted order. |
Single<List<T>> | toSortedList(Comparator<? superT> comparator) Returns a Single that emits a list that contains the items emitted by the finite source ObservableSource, in a sorted order based on a specified comparison function. |
Single<List<T>> | toSortedList(Comparator<? superT> comparator, int capacityHint) Returns a Single that emits a list that contains the items emitted by the finite source ObservableSource, in a sorted order based on a specified comparison function. |
Single<List<T>> | toSortedList(int capacityHint) Returns a Single that emits a list that contains the items emitted by the finite source ObservableSource, in a sorted order. |
static <T> Observable<T> | unsafeCreate(ObservableSource<T> onSubscribe) Create an Observable by wrapping an ObservableSourcewhich has to be implemented according to the Reactive Streams based Observable specification by handling disposal correctly; no safeguards are provided by the Observable itself. |
Observable<T> | unsubscribeOn(Scheduler scheduler) Modifies the source ObservableSource so that subscribers will dispose it on a specified Scheduler . |
static <T,D> Observable<T> | using(Callable<? extends D> resourceSupplier,Function<? super D,? extendsObservableSource<? extends T>> sourceSupplier,Consumer<? super D> disposer) Constructs an ObservableSource that creates a dependent resource object which is disposed of when the downstream calls dispose(). |
static <T,D> Observable<T> | using(Callable<? extends D> resourceSupplier,Function<? super D,? extendsObservableSource<? extends T>> sourceSupplier,Consumer<? super D> disposer, boolean eager) Constructs an ObservableSource that creates a dependent resource object which is disposed of just before termination if you have set disposeEagerly totrue and a dispose() call does not occur before termination. |
<B> Observable<Observable<T>> | window(Callable<? extendsObservableSource<B>> boundary) Returns an Observable that emits windows of items it collects from the source ObservableSource. |
<B> Observable<Observable<T>> | window(Callable<? extendsObservableSource<B>> boundary, int bufferSize) Returns an Observable that emits windows of items it collects from the source ObservableSource. |
Observable<Observable<T>> | window(long count) Returns an Observable that emits windows of items it collects from the source ObservableSource. |
Observable<Observable<T>> | window(long count, long skip) Returns an Observable that emits windows of items it collects from the source ObservableSource. |
Observable<Observable<T>> | window(long count, long skip, int bufferSize) Returns an Observable that emits windows of items it collects from the source ObservableSource. |
Observable<Observable<T>> | window(long timespan, long timeskip,TimeUnit unit) Returns an Observable that emits windows of items it collects from the source ObservableSource. |
Observable<Observable<T>> | window(long timespan, long timeskip,TimeUnit unit,Scheduler scheduler) Returns an Observable that emits windows of items it collects from the source ObservableSource. |
Observable<Observable<T>> | window(long timespan, long timeskip,TimeUnit unit,Scheduler scheduler, int bufferSize) Returns an Observable that emits windows of items it collects from the source ObservableSource. |
Observable<Observable<T>> | window(long timespan,TimeUnit unit) Returns an Observable that emits windows of items it collects from the source ObservableSource. |
Observable<Observable<T>> | window(long timespan,TimeUnit unit, long count) Returns an Observable that emits windows of items it collects from the source ObservableSource. |
Observable<Observable<T>> | window(long timespan,TimeUnit unit, long count, boolean restart) Returns an Observable that emits windows of items it collects from the source ObservableSource. |
Observable<Observable<T>> | window(long timespan,TimeUnit unit,Scheduler scheduler) Returns an Observable that emits windows of items it collects from the source ObservableSource. |
Observable<Observable<T>> | window(long timespan,TimeUnit unit,Scheduler scheduler, long count) Returns an Observable that emits windows of items it collects from the source ObservableSource. |
Observable<Observable<T>> | window(long timespan,TimeUnit unit,Scheduler scheduler, long count, boolean restart) Returns an Observable that emits windows of items it collects from the source ObservableSource. |
Observable<Observable<T>> | window(long timespan,TimeUnit unit,Scheduler scheduler, long count, boolean restart, int bufferSize) Returns an Observable that emits windows of items it collects from the source ObservableSource. |
<B> Observable<Observable<T>> | window(ObservableSource<B> boundary) Returns an Observable that emits non-overlapping windows of items it collects from the source ObservableSource where the boundary of each window is determined by the items emitted from a specified boundary-governing ObservableSource. |
<B> Observable<Observable<T>> | window(ObservableSource<B> boundary, int bufferSize) Returns an Observable that emits non-overlapping windows of items it collects from the source ObservableSource where the boundary of each window is determined by the items emitted from a specified boundary-governing ObservableSource. |
<U,V> Observable<Observable<T>> | window(ObservableSource<U> openingIndicator,Function<? super U,? extendsObservableSource<V>> closingIndicator) Returns an Observable that emits windows of items it collects from the source ObservableSource. |
<U,V> Observable<Observable<T>> | window(ObservableSource<U> openingIndicator,Function<? super U,? extendsObservableSource<V>> closingIndicator, int bufferSize) Returns an Observable that emits windows of items it collects from the source ObservableSource. |
<R> Observable<R> | withLatestFrom(Iterable<? extendsObservableSource<?>> others,Function<? superObject[],R> combiner) Combines the value emission from this ObservableSource with the latest emissions from the other ObservableSources via a function to produce the output item. |
<R> Observable<R> | withLatestFrom(ObservableSource<?>[] others,Function<? superObject[],R> combiner) Combines the value emission from this ObservableSource with the latest emissions from the other ObservableSources via a function to produce the output item. |
<U,R> Observable<R> | withLatestFrom(ObservableSource<? extends U> other,BiFunction<? superT,? super U,? extends R> combiner) Merges the specified ObservableSource into this ObservableSource sequence by using the resultSelector function only when the source ObservableSource (this instance) emits an item. |
<T1,T2,R> Observable<R> | withLatestFrom(ObservableSource<T1> o1,ObservableSource<T2> o2,Function3<? superT,? super T1,? super T2,R> combiner) Combines the value emission from this ObservableSource with the latest emissions from the other ObservableSources via a function to produce the output item. |
<T1,T2,T3,R> | withLatestFrom(ObservableSource<T1> o1,ObservableSource<T2> o2,ObservableSource<T3> o3,Function4<? superT,? super T1,? super T2,? super T3,R> combiner) Combines the value emission from this ObservableSource with the latest emissions from the other ObservableSources via a function to produce the output item. |
<T1,T2,T3,T4,R> | withLatestFrom(ObservableSource<T1> o1,ObservableSource<T2> o2,ObservableSource<T3> o3,ObservableSource<T4> o4,Function5<? superT,? super T1,? super T2,? super T3,? super T4,R> combiner) Combines the value emission from this ObservableSource with the latest emissions from the other ObservableSources via a function to produce the output item. |
static <T> Observable<T> | wrap(ObservableSource<T> source) Wraps an ObservableSource into an Observable if not already an Observable. |
static <T,R> Observable<R> | zip(Iterable<? extendsObservableSource<? extends T>> sources,Function<? superObject[],? extends R> zipper) Returns an Observable that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by an Iterable of other ObservableSources. |
static <T,R> Observable<R> | zip(ObservableSource<? extendsObservableSource<? extends T>> sources,Function<? superObject[],? extends R> zipper) Returns an Observable that emits the results of a specified combiner function applied to combinations ofn items emitted, in sequence, by then ObservableSources emitted by a specified ObservableSource. |
static <T1,T2,R> Observable<R> | zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,BiFunction<? super T1,? super T2,? extends R> zipper) Returns an Observable that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two other ObservableSources. |
static <T1,T2,R> Observable<R> | zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,BiFunction<? super T1,? super T2,? extends R> zipper, boolean delayError) Returns an Observable that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two other ObservableSources. |
static <T1,T2,R> Observable<R> | zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,BiFunction<? super T1,? super T2,? extends R> zipper, boolean delayError, int bufferSize) Returns an Observable that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two other ObservableSources. |
static <T1,T2,T3,R> | zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,Function3<? super T1,? super T2,? super T3,? extends R> zipper) Returns an Observable that emits the results of a specified combiner function applied to combinations of three items emitted, in sequence, by three other ObservableSources. |
static <T1,T2,T3,T4,R> | zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,Function4<? super T1,? super T2,? super T3,? super T4,? extends R> zipper) Returns an Observable that emits the results of a specified combiner function applied to combinations of four items emitted, in sequence, by four other ObservableSources. |
static <T1,T2,T3,T4,T5,R> | zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,Function5<? super T1,? super T2,? super T3,? super T4,? super T5,? extends R> zipper) Returns an Observable that emits the results of a specified combiner function applied to combinations of five items emitted, in sequence, by five other ObservableSources. |
static <T1,T2,T3,T4,T5,T6,R> | zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,ObservableSource<? extends T6> source6,Function6<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? extends R> zipper) Returns an Observable that emits the results of a specified combiner function applied to combinations of six items emitted, in sequence, by six other ObservableSources. |
static <T1,T2,T3,T4,T5,T6,T7,R> | zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,ObservableSource<? extends T6> source6,ObservableSource<? extends T7> source7,Function7<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? extends R> zipper) Returns an Observable that emits the results of a specified combiner function applied to combinations of seven items emitted, in sequence, by seven other ObservableSources. |
static <T1,T2,T3,T4,T5,T6,T7,T8,R> | zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,ObservableSource<? extends T6> source6,ObservableSource<? extends T7> source7,ObservableSource<? extends T8> source8,Function8<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? extends R> zipper) Returns an Observable that emits the results of a specified combiner function applied to combinations of eight items emitted, in sequence, by eight other ObservableSources. |
static <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> | zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,ObservableSource<? extends T6> source6,ObservableSource<? extends T7> source7,ObservableSource<? extends T8> source8,ObservableSource<? extends T9> source9,Function9<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? super T9,? extends R> zipper) Returns an Observable that emits the results of a specified combiner function applied to combinations of nine items emitted, in sequence, by nine other ObservableSources. |
static <T,R> Observable<R> | zipArray(Function<? superObject[],? extends R> zipper, boolean delayError, int bufferSize,ObservableSource<? extends T>... sources) Returns an Observable that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by an array of other ObservableSources. |
static <T,R> Observable<R> | zipIterable(Iterable<? extendsObservableSource<? extends T>> sources,Function<? superObject[],? extends R> zipper, boolean delayError, int bufferSize) Returns an Observable that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by an Iterable of other ObservableSources. |
<U,R> Observable<R> | zipWith(Iterable<U> other,BiFunction<? superT,? super U,? extends R> zipper) Returns an Observable that emits items that are the result of applying a specified function to pairs of values, one each from the source ObservableSource and a specified Iterable sequence. |
<U,R> Observable<R> | zipWith(ObservableSource<? extends U> other,BiFunction<? superT,? super U,? extends R> zipper) Returns an Observable that emits items that are the result of applying a specified function to pairs of values, one each from the source ObservableSource and another specified ObservableSource. |
<U,R> Observable<R> | zipWith(ObservableSource<? extends U> other,BiFunction<? superT,? super U,? extends R> zipper, boolean delayError) Returns an Observable that emits items that are the result of applying a specified function to pairs of values, one each from the source ObservableSource and another specified ObservableSource. |
<U,R> Observable<R> | zipWith(ObservableSource<? extends U> other,BiFunction<? superT,? super U,? extends R> zipper, boolean delayError, int bufferSize) Returns an Observable that emits items that are the result of applying a specified function to pairs of values, one each from the source ObservableSource and another specified ObservableSource. |
@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> amb(Iterable<? extendsObservableSource<? extends T>> sources)
amb
does not operate by default on a particularScheduler
.T
- the common element typesources
- an Iterable of ObservableSource sources competing to react first. A subscription to each source will occur in the same order as in the Iterable.@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> ambArray(ObservableSource<? extends T>... sources)
ambArray
does not operate by default on a particularScheduler
.T
- the common element typesources
- an array of ObservableSource sources competing to react first. A subscription to each source will occur in the same order as in the array.public static int bufferSize()
Delegates toFlowable.bufferSize()
but is public for convenience.
The value can be overridden via system parameterrx2.buffer-size
before theFlowable
class is loaded.
@CheckReturnValue@SchedulerSupport(value="none")public static <T,R> Observable<R> combineLatest(Function<? superObject[],? extends R> combiner, int bufferSize,ObservableSource<? extends T>... sources)
Note on method signature: since Java doesn't allow creating a generic array withnew 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 there are no ObservableSources provided, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.
combineLatest
does not operate by default on a particularScheduler
.T
- the common base type of source valuesR
- the result typesources
- the collection of source ObservableSourcescombiner
- the aggregation function used to combine the items emitted by the source ObservableSourcesbufferSize
- the internal buffer size and prefetch amount applied to every source Observable@CheckReturnValue@SchedulerSupport(value="none")public static <T,R> Observable<R> combineLatest(Iterable<? extendsObservableSource<? extends T>> sources,Function<? superObject[],? extends R> combiner)
Note on method signature: since Java doesn't allow creating a generic array withnew 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 ObservableSources is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.
combineLatest
does not operate by default on a particularScheduler
.T
- the common base type of source valuesR
- the result typesources
- the collection of source ObservableSourcescombiner
- the aggregation function used to combine the items emitted by the source ObservableSources@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T,R> Observable<R> combineLatest(Iterable<? extendsObservableSource<? extends T>> sources,Function<? superObject[],? extends R> combiner, int bufferSize)
Note on method signature: since Java doesn't allow creating a generic array withnew 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 ObservableSources is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.
combineLatest
does not operate by default on a particularScheduler
.T
- the common base type of source valuesR
- the result typesources
- the collection of source ObservableSourcescombiner
- the aggregation function used to combine the items emitted by the source ObservableSourcesbufferSize
- the internal buffer size and prefetch amount applied to every source Observable@CheckReturnValue@SchedulerSupport(value="none")public static <T,R> Observable<R> combineLatest(ObservableSource<? extends T>[] sources,Function<? superObject[],? extends R> combiner)
Note on method signature: since Java doesn't allow creating a generic array withnew 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 ObservableSources is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.
combineLatest
does not operate by default on a particularScheduler
.T
- the common base type of source valuesR
- the result typesources
- the collection of source ObservableSourcescombiner
- the aggregation function used to combine the items emitted by the source ObservableSources@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T,R> Observable<R> combineLatest(ObservableSource<? extends T>[] sources,Function<? superObject[],? extends R> combiner, int bufferSize)
Note on method signature: since Java doesn't allow creating a generic array withnew 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 ObservableSources is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.
combineLatest
does not operate by default on a particularScheduler
.T
- the common base type of source valuesR
- the result typesources
- the collection of source ObservableSourcescombiner
- the aggregation function used to combine the items emitted by the source ObservableSourcesbufferSize
- the internal buffer size and prefetch amount applied to every source Observable@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,R> Observable<R> combineLatest(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,BiFunction<? super T1,? super T2,? extends R> combiner)
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.
combineLatest
does not operate by default on a particularScheduler
.T1
- the element type of the first sourceT2
- the element type of the second sourceR
- the combined output typesource1
- the first source ObservableSourcesource2
- the second source ObservableSourcecombiner
- the aggregation function used to combine the items emitted by the source ObservableSources@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,R> Observable<R> combineLatest(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,Function3<? super T1,? super T2,? super T3,? extends R> combiner)
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.
combineLatest
does not operate by default on a particularScheduler
.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 typesource1
- the first source ObservableSourcesource2
- the second source ObservableSourcesource3
- the third source ObservableSourcecombiner
- the aggregation function used to combine the items emitted by the source ObservableSources@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,R> Observable<R> combineLatest(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,Function4<? super T1,? super T2,? super T3,? super T4,? extends R> combiner)
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.
combineLatest
does not operate by default on a particularScheduler
.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 typesource1
- the first source ObservableSourcesource2
- the second source ObservableSourcesource3
- the third source ObservableSourcesource4
- the fourth source ObservableSourcecombiner
- the aggregation function used to combine the items emitted by the source ObservableSources@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,R> Observable<R> combineLatest(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,Function5<? super T1,? super T2,? super T3,? super T4,? super T5,? extends R> combiner)
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.
combineLatest
does not operate by default on a particularScheduler
.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 typesource1
- the first source ObservableSourcesource2
- the second source ObservableSourcesource3
- the third source ObservableSourcesource4
- the fourth source ObservableSourcesource5
- the fifth source ObservableSourcecombiner
- the aggregation function used to combine the items emitted by the source ObservableSources@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,T6,R> Observable<R> combineLatest(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,ObservableSource<? extends T6> source6,Function6<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? extends R> combiner)
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.
combineLatest
does not operate by default on a particularScheduler
.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 typesource1
- the first source ObservableSourcesource2
- the second source ObservableSourcesource3
- the third source ObservableSourcesource4
- the fourth source ObservableSourcesource5
- the fifth source ObservableSourcesource6
- the sixth source ObservableSourcecombiner
- the aggregation function used to combine the items emitted by the source ObservableSources@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,T6,T7,R> Observable<R> combineLatest(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,ObservableSource<? extends T6> source6,ObservableSource<? extends T7> source7,Function7<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? extends R> combiner)
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.
combineLatest
does not operate by default on a particularScheduler
.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 typesource1
- the first source ObservableSourcesource2
- the second source ObservableSourcesource3
- the third source ObservableSourcesource4
- the fourth source ObservableSourcesource5
- the fifth source ObservableSourcesource6
- the sixth source ObservableSourcesource7
- the seventh source ObservableSourcecombiner
- the aggregation function used to combine the items emitted by the source ObservableSources@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,T6,T7,T8,R> Observable<R> combineLatest(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,ObservableSource<? extends T6> source6,ObservableSource<? extends T7> source7,ObservableSource<? extends T8> source8,Function8<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? extends R> combiner)
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.
combineLatest
does not operate by default on a particularScheduler
.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 typesource1
- the first source ObservableSourcesource2
- the second source ObservableSourcesource3
- the third source ObservableSourcesource4
- the fourth source ObservableSourcesource5
- the fifth source ObservableSourcesource6
- the sixth source ObservableSourcesource7
- the seventh source ObservableSourcesource8
- the eighth source ObservableSourcecombiner
- the aggregation function used to combine the items emitted by the source ObservableSources@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> Observable<R> combineLatest(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,ObservableSource<? extends T6> source6,ObservableSource<? extends T7> source7,ObservableSource<? extends T8> source8,ObservableSource<? extends T9> source9,Function9<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? super T9,? extends R> combiner)
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.
combineLatest
does not operate by default on a particularScheduler
.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 typesource1
- the first source ObservableSourcesource2
- the second source ObservableSourcesource3
- the third source ObservableSourcesource4
- the fourth source ObservableSourcesource5
- the fifth source ObservableSourcesource6
- the sixth source ObservableSourcesource7
- the seventh source ObservableSourcesource8
- the eighth source ObservableSourcesource9
- the ninth source ObservableSourcecombiner
- the aggregation function used to combine the items emitted by the source ObservableSources@CheckReturnValue@SchedulerSupport(value="none")public static <T,R> Observable<R> combineLatestDelayError(ObservableSource<? extends T>[] sources,Function<? superObject[],? extends R> combiner)
Note on method signature: since Java doesn't allow creating a generic array withnew 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 ObservableSources is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.
combineLatestDelayError
does not operate by default on a particularScheduler
.T
- the common base type of source valuesR
- the result typesources
- the collection of source ObservableSourcescombiner
- the aggregation function used to combine the items emitted by the source ObservableSources@CheckReturnValue@SchedulerSupport(value="none")public static <T,R> Observable<R> combineLatestDelayError(Function<? superObject[],? extends R> combiner, int bufferSize,ObservableSource<? extends T>... sources)
Note on method signature: since Java doesn't allow creating a generic array withnew 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 there are no ObservableSources provided, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.
combineLatestDelayError
does not operate by default on a particularScheduler
.T
- the common base type of source valuesR
- the result typesources
- the collection of source ObservableSourcescombiner
- the aggregation function used to combine the items emitted by the source ObservableSourcesbufferSize
- the internal buffer size and prefetch amount applied to every source Observable@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T,R> Observable<R> combineLatestDelayError(ObservableSource<? extends T>[] sources,Function<? superObject[],? extends R> combiner, int bufferSize)
Note on method signature: since Java doesn't allow creating a generic array withnew 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 ObservableSources is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.
combineLatestDelayError
does not operate by default on a particularScheduler
.T
- the common base type of source valuesR
- the result typesources
- the collection of source ObservableSourcescombiner
- the aggregation function used to combine the items emitted by the source ObservableSourcesbufferSize
- the internal buffer size and prefetch amount applied to every source Observable@CheckReturnValue@SchedulerSupport(value="none")public static <T,R> Observable<R> combineLatestDelayError(Iterable<? extendsObservableSource<? extends T>> sources,Function<? superObject[],? extends R> combiner)
Note on method signature: since Java doesn't allow creating a generic array withnew 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 ObservableSources is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.
combineLatestDelayError
does not operate by default on a particularScheduler
.T
- the common base type of source valuesR
- the result typesources
- the collection of source ObservableSourcescombiner
- the aggregation function used to combine the items emitted by the source ObservableSources@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T,R> Observable<R> combineLatestDelayError(Iterable<? extendsObservableSource<? extends T>> sources,Function<? superObject[],? extends R> combiner, int bufferSize)
Note on method signature: since Java doesn't allow creating a generic array withnew 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 ObservableSources is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.
combineLatestDelayError
does not operate by default on a particularScheduler
.T
- the common base type of source valuesR
- the result typesources
- the collection of source ObservableSourcescombiner
- the aggregation function used to combine the items emitted by the source ObservableSourcesbufferSize
- the internal buffer size and prefetch amount applied to every source Observable@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> concat(Iterable<? extendsObservableSource<? extends T>> sources)
concat
does not operate by default on a particularScheduler
.T
- the common value type of the sourcessources
- the Iterable sequence of ObservableSources@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> concat(ObservableSource<? extendsObservableSource<? extends T>> sources)
concat
does not operate by default on a particularScheduler
.T
- the common element base typesources
- an ObservableSource that emits ObservableSourcesObservableSources
, one after the other, without interleaving them@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> concat(ObservableSource<? extendsObservableSource<? extends T>> sources, int prefetch)
concat
does not operate by default on a particularScheduler
.T
- the common element base typesources
- an ObservableSource that emits ObservableSourcesprefetch
- the number of ObservableSources to prefetch from the sources sequence.ObservableSources
, one after the other, without interleaving them@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> concat(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2)
concat
does not operate by default on a particularScheduler
.T
- the common element base typesource1
- an ObservableSource to be concatenatedsource2
- an ObservableSource to be concatenated@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> concat(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2,ObservableSource<? extends T> source3)
concat
does not operate by default on a particularScheduler
.T
- the common element base typesource1
- an ObservableSource to be concatenatedsource2
- an ObservableSource to be concatenatedsource3
- an ObservableSource to be concatenated@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> concat(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2,ObservableSource<? extends T> source3,ObservableSource<? extends T> source4)
concat
does not operate by default on a particularScheduler
.T
- the common element base typesource1
- an ObservableSource to be concatenatedsource2
- an ObservableSource to be concatenatedsource3
- an ObservableSource to be concatenatedsource4
- an ObservableSource to be concatenated@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> concatArray(ObservableSource<? extends T>... sources)
Note: named this way because of overload conflict with concat(ObservableSource<ObservableSource>)
concatArray
does not operate by default on a particularScheduler
.T
- the common base value typesources
- the array of sourcesNullPointerException
- if sources is null@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> concatArrayDelayError(ObservableSource<? extends T>... sources)
concatArrayDelayError
does not operate by default on a particularScheduler
.T
- the common base value typesources
- the array of sourcesNullPointerException
- if sources is null@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> concatArrayEager(ObservableSource<? extends T>... sources)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typesources
- an array of ObservableSources that need to be eagerly concatenated@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> concatArrayEager(int maxConcurrency, int prefetch,ObservableSource<? extends T>... sources)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typesources
- an array of ObservableSources 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 onceprefetch
- the number of elements to prefetch from each ObservableSource source@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> concatArrayEagerDelayError(ObservableSource<? extends T>... sources)
ObservableSource
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 sourceObservableSource
s. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typesources
- an array ofObservableSource
s that need to be eagerly concatenated@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> concatArrayEagerDelayError(int maxConcurrency, int prefetch,ObservableSource<? extends T>... sources)
ObservableSource
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 sourceObservableSource
s. The operator buffers the values emitted by theseObservableSource
s and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typesources
- 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 onceprefetch
- the number of elements to prefetch from eachObservableSource
source@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> concatDelayError(Iterable<? extendsObservableSource<? extends T>> sources)
concatDelayError
does not operate by default on a particularScheduler
.T
- the common element base typesources
- the Iterable sequence of ObservableSources@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> concatDelayError(ObservableSource<? extendsObservableSource<? extends T>> sources)
concatDelayError
does not operate by default on a particularScheduler
.T
- the common element base typesources
- the ObservableSource sequence of ObservableSources@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> concatDelayError(ObservableSource<? extendsObservableSource<? extends T>> sources, int prefetch, boolean tillTheEnd)
concatDelayError
does not operate by default on a particularScheduler
.T
- the common element base typesources
- the ObservableSource sequence of ObservableSourcesprefetch
- the number of elements to prefetch from the outer ObservableSourcetillTheEnd
- if true exceptions from the outer and all inner ObservableSources are delayed to the end if false, exception from the outer ObservableSource is delayed till the current ObservableSource terminates@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> concatEager(ObservableSource<? extendsObservableSource<? extends T>> sources)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source ObservableSources as they are observed. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typesources
- a sequence of ObservableSources that need to be eagerly concatenated@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> concatEager(ObservableSource<? extendsObservableSource<? extends T>> sources, int maxConcurrency, int prefetch)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source ObservableSources as they are observed. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typesources
- a sequence of ObservableSources that need to be eagerly concatenatedmaxConcurrency
- the maximum number of concurrently running inner ObservableSources; Integer.MAX_VALUE is interpreted as all inner ObservableSources can be active at the same timeprefetch
- the number of elements to prefetch from each inner ObservableSource source@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> concatEager(Iterable<? extendsObservableSource<? extends T>> sources)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typesources
- a sequence of ObservableSources that need to be eagerly concatenated@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> concatEager(Iterable<? extendsObservableSource<? extends T>> sources, int maxConcurrency, int prefetch)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typesources
- a sequence of ObservableSources that need to be eagerly concatenatedmaxConcurrency
- the maximum number of concurrently running inner ObservableSources; Integer.MAX_VALUE is interpreted as all inner ObservableSources can be active at the same timeprefetch
- the number of elements to prefetch from each inner ObservableSource source@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> create(ObservableOnSubscribe<T> source)
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); });
You should call the ObservableEmitter's onNext, onError and onComplete methods in a serialized fashion. The rest of its methods are thread-safe.
create
does not operate by default on a particularScheduler
.T
- the element typesource
- the emitter that is called when an Observer subscribes to the returnedObservable
ObservableOnSubscribe
,ObservableEmitter
,Cancellable
@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> defer(Callable<? extendsObservableSource<? extends T>> supplier)
The defer Observer allows you to defer or delay emitting items from an ObservableSource until such time as an Observer subscribes to the ObservableSource. This allows anObserver
to easily obtain updates or a refreshed version of the sequence.
defer
does not operate by default on a particularScheduler
.T
- the type of the items emitted by the ObservableSourcesupplier
- the ObservableSource factory function to invoke for eachObserver
that subscribes to the resulting ObservableSourceObserver
s' subscriptions trigger an invocation of the given ObservableSource factory function@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> empty()
Observer
and immediately invokes itsonComplete
method.empty
does not operate by default on a particularScheduler
.T
- the type of the items (ostensibly) emitted by the ObservableSourceObserver
but immediately invokes theObserver
'sonComplete
method@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> error(Callable<? extendsThrowable> errorSupplier)
Observer
'sonError
method when the Observer subscribes to it.error
does not operate by default on a particularScheduler
.T
- the type of the items (ostensibly) emitted by the ObservableSourceerrorSupplier
- a Callable factory to return a Throwable for each individual ObserverObserver
'sonError
method when the Observer subscribes to it@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> error(Throwable exception)
Observer
'sonError
method when the Observer subscribes to it.error
does not operate by default on a particularScheduler
.T
- the type of the items (ostensibly) emitted by the ObservableSourceexception
- the particular Throwable to pass toonError
Observer
'sonError
method when the Observer subscribes to it@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> Observable<T> fromArray(T... items)
fromArray
does not operate by default on a particularScheduler
.T
- the type of items in the Array and the type of items to be emitted by the resulting ObservableSourceitems
- the array of elements@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> fromCallable(Callable<? extends T> supplier)
This allows you to defer the execution of the function you specify until an observer subscribes to the ObservableSource. That is to say, it makes the function "lazy."
fromCallable
does not operate by default on a particularScheduler
.Callable
throws an exception, the respectiveThrowable
is delivered to the downstream viaObserver.onError(Throwable)
, except when the downstream has disposed thisObservable
source. In this latter case, theThrowable
is delivered to the global error handler viaRxJavaPlugins.onError(Throwable)
as anUndeliverableException
.T
- the type of the item emitted by the ObservableSourcesupplier
- a function, the execution of which should be deferred;fromCallable
will invoke this function only when an observer subscribes to the ObservableSource thatfromCallable
returnsObserver
s' subscriptions trigger an invocation of the given functiondefer(Callable)
@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> fromFuture(Future<? extends T> future)
Future
into an ObservableSource. You can convert any object that supports theFuture
interface into an ObservableSource that emits the return value of theFuture.get()
method of that object, by passing the object into thefrom
method.
Important note: This ObservableSource is blocking; you cannot dispose it.
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));
.
fromFuture
does not operate by default on a particularScheduler
.T
- the type of object that theFuture
returns, and also the type of item to be emitted by the resulting ObservableSourcefuture
- the sourceFuture
Future
@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> fromFuture(Future<? extends T> future, long timeout,TimeUnit unit)
Future
into an ObservableSource, with a timeout on the Future. You can convert any object that supports theFuture
interface into an ObservableSource that emits the return value of theFuture.get()
method of that object, by passing the object into thefrom
method.
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));
.
Important note: This ObservableSource is blocking; you cannot dispose it.
fromFuture
does not operate by default on a particularScheduler
.T
- the type of object that theFuture
returns, and also the type of item to be emitted by the resulting ObservableSourcefuture
- the sourceFuture
timeout
- the maximum time to wait before callingget
unit
- theTimeUnit
of thetimeout
argumentFuture
@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public static <T> Observable<T> fromFuture(Future<? extends T> future, long timeout,TimeUnit unit,Scheduler scheduler)
Future
into an ObservableSource, with a timeout on the Future. You can convert any object that supports theFuture
interface into an ObservableSource that emits the return value of theFuture.get()
method of that object, by passing the object into thefrom
method.
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));
.
Important note: This ObservableSource is blocking; you cannot dispose it.
fromFuture
does not operate by default on a particularScheduler
.T
- the type of object that theFuture
returns, and also the type of item to be emitted by the resulting ObservableSourcefuture
- the sourceFuture
timeout
- the maximum time to wait before callingget
unit
- theTimeUnit
of thetimeout
argumentscheduler
- theScheduler
to wait for the Future on. Use a Scheduler such asSchedulers.io()
that can block and wait on the FutureFuture
@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public static <T> Observable<T> fromFuture(Future<? extends T> future,Scheduler scheduler)
Future
, operating on a specifiedScheduler
, into an ObservableSource. You can convert any object that supports theFuture
interface into an ObservableSource that emits the return value of theFuture.get()
method of that object, by passing the object into thefrom
method.
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));
.
Scheduler
this operator will use.T
- the type of object that theFuture
returns, and also the type of item to be emitted by the resulting ObservableSourcefuture
- the sourceFuture
scheduler
- theScheduler
to wait for the Future on. Use a Scheduler such asSchedulers.io()
that can block and wait on the FutureFuture
@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> fromIterable(Iterable<? extends T> source)
Iterable
sequence into an ObservableSource that emits the items in the sequence.fromIterable
does not operate by default on a particularScheduler
.T
- the type of items in theIterable
sequence and the type of items to be emitted by the resulting ObservableSourcesource
- the sourceIterable
sequenceIterable
sequence@BackpressureSupport(value=UNBOUNDED_IN)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> fromPublisher(Publisher<? extends T> publisher)
ThePublisher
must follow theReactive Streams specification. Violating the specification may result in undefined behavior.
If possible, usecreate(ObservableOnSubscribe)
to create a source-likeObservable
instead.
Note that even thoughPublisher
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.
publisher
is consumed in an unbounded fashion without applying any backpressure to it.fromPublisher
does not operate by default on a particularScheduler
.T
- the value type of the flowpublisher
- the Publisher to convertNullPointerException
- if publisher is nullcreate(ObservableOnSubscribe)
@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> generate(Consumer<Emitter<T>> generator)
Note that theEmitter.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.
generate
does not operate by default on a particularScheduler
.T
- the generated value typegenerator
- the Consumer called whenever a particular downstream Observer has requested a value. The callback then should callonNext
,onError
oronComplete
to signal a value or a terminal event. Signalling multipleonNext
in a call will make the operator signalIllegalStateException
.@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T,S> Observable<T> generate(Callable<S> initialState,BiConsumer<S,Emitter<T>> generator)
Note that theEmitter.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.
generate
does not operate by default on a particularScheduler
.S
- the type of the per-Observer stateT
- the generated value typeinitialState
- the Callable to generate the initial state for each Observergenerator
- the Consumer called with the current state whenever a particular downstream Observer has requested a value. The callback then should callonNext
,onError
oronComplete
to signal a value or a terminal event. Signalling multipleonNext
in a call will make the operator signalIllegalStateException
.@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T,S> Observable<T> generate(Callable<S> initialState,BiConsumer<S,Emitter<T>> generator,Consumer<? super S> disposeState)
Note that theEmitter.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.
generate
does not operate by default on a particularScheduler
.S
- the type of the per-Observer stateT
- the generated value typeinitialState
- the Callable to generate the initial state for each Observergenerator
- the Consumer called with the current state whenever a particular downstream Observer has requested a value. The callback then should callonNext
,onError
oronComplete
to signal a value or a terminal event. Signalling multipleonNext
in a call will make the operator signalIllegalStateException
.disposeState
- the Consumer that is called with the current state when the generator terminates the sequence or it gets disposed@CheckReturnValue@SchedulerSupport(value="none")public static <T,S> Observable<T> generate(Callable<S> initialState,BiFunction<S,Emitter<T>,S> generator)
Note that theEmitter.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.
generate
does not operate by default on a particularScheduler
.S
- the type of the per-Observer stateT
- the generated value typeinitialState
- the Callable to generate the initial state for each Observergenerator
- the Function called with the current state whenever a particular downstream Observer has requested a value. 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. Signalling multipleonNext
in a call will make the operator signalIllegalStateException
.@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T,S> Observable<T> generate(Callable<S> initialState,BiFunction<S,Emitter<T>,S> generator,Consumer<? super S> disposeState)
Note that theEmitter.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.
generate
does not operate by default on a particularScheduler
.S
- the type of the per-Observer stateT
- the generated value typeinitialState
- the Callable to generate the initial state for each Observergenerator
- the Function called with the current state whenever a particular downstream Observer has requested a value. 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. Signalling multipleonNext
in a call will make the operator signalIllegalStateException
.disposeState
- the Consumer that is called with the current state when the generator terminates the sequence or it gets disposed@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public static Observable<Long> interval(long initialDelay, long period,TimeUnit unit)
0L
after theinitialDelay
and ever increasing numbers after eachperiod
of time thereafter.interval
operates by default on thecomputation
Scheduler
.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
initialDelay
and ever increasing numbers after eachperiod
of time thereafter@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public static Observable<Long> interval(long initialDelay, long period,TimeUnit unit,Scheduler scheduler)
0L
after theinitialDelay
and ever increasing numbers after eachperiod
of time thereafter, on a specifiedScheduler
.Scheduler
this operator will use.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
- the Scheduler on which the waiting happens and items are emittedinitialDelay
and ever increasing numbers after eachperiod
of time thereafter, while running on the given Scheduler@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public static Observable<Long> interval(long period,TimeUnit unit)
interval
operates by default on thecomputation
Scheduler
.period
- the period size in time units (see below)unit
- time units to use for the interval size@CheckReturnValue@SchedulerSupport(value="custom")public static Observable<Long> interval(long period,TimeUnit unit,Scheduler scheduler)
Scheduler
this operator will use.period
- the period size in time units (see below)unit
- time units to use for the interval sizescheduler
- the Scheduler to use for scheduling the items@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public static Observable<Long> intervalRange(long start, long count, long initialDelay, long period,TimeUnit unit)
The sequence completes immediately after the last value (start + count - 1) has been reached.
intervalRange
by default operates on thecomputation
Scheduler
.start
- that start value of the rangecount
- the number of values to emit in total, if zero, the operator emits an onComplete after the initial delay.initialDelay
- the initial delay before signalling the first value (the start)period
- the period between subsequent valuesunit
- the unit of measure of the initialDelay and period amounts@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public static Observable<Long> intervalRange(long start, long count, long initialDelay, long period,TimeUnit unit,Scheduler scheduler)
The sequence completes immediately after the last value (start + count - 1) has been reached.
*
Scheduler
.start
- that start value of the rangecount
- the number of values to emit in total, if zero, the operator emits an onComplete after the initial delay.initialDelay
- the initial delay before signalling the first value (the start)period
- the period between subsequent valuesunit
- the unit of measure of the initialDelay and period amountsscheduler
- the target scheduler where the values and terminal signals will be emitted@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> just(T item)
Note that the item is taken and re-emitted as is and not computed by any means byjust
. UsefromCallable(Callable)
to generate a single item on demand (whenObserver
s subscribe to it).
See the multi-parameter overloads ofjust
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 anIterable
sequence (such as aList
), usefromIterable(Iterable)
.
just
does not operate by default on a particularScheduler
.T
- the type of that itemitem
- the item to emitvalue
as a single item and then completesjust(Object, Object)
,fromCallable(Callable)
,fromArray(Object...)
,fromIterable(Iterable)
@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> just(T item1, T item2)
just
does not operate by default on a particularScheduler
.T
- the type of these itemsitem1
- first itemitem2
- second item@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> just(T item1, T item2, T item3)
just
does not operate by default on a particularScheduler
.T
- the type of these itemsitem1
- first itemitem2
- second itemitem3
- third item@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> just(T item1, T item2, T item3, T item4)
just
does not operate by default on a particularScheduler
.T
- the type of these itemsitem1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth item@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> just(T item1, T item2, T item3, T item4, T item5)
just
does not operate by default on a particularScheduler
.T
- the type of these itemsitem1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth item@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> just(T item1, T item2, T item3, T item4, T item5, T item6)
just
does not operate by default on a particularScheduler
.T
- the type of these itemsitem1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth itemitem6
- sixth item@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> just(T item1, T item2, T item3, T item4, T item5, T item6, T item7)
just
does not operate by default on a particularScheduler
.T
- the type of these itemsitem1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth itemitem6
- sixth itemitem7
- seventh item@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> just(T item1, T item2, T item3, T item4, T item5, T item6, T item7, T item8)
just
does not operate by default on a particularScheduler
.T
- the type of these itemsitem1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth itemitem6
- sixth itemitem7
- seventh itemitem8
- eighth item@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> just(T item1, T item2, T item3, T item4, T item5, T item6, T item7, T item8, T item9)
just
does not operate by default on a particularScheduler
.T
- the type of these itemsitem1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth itemitem6
- sixth itemitem7
- seventh itemitem8
- eighth itemitem9
- ninth item@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> just(T item1, T item2, T item3, T item4, T item5, T item6, T item7, T item8, T item9, T item10)
just
does not operate by default on a particularScheduler
.T
- the type of these itemsitem1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth itemitem6
- sixth itemitem7
- seventh itemitem8
- eighth itemitem9
- ninth itemitem10
- tenth item@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> merge(Iterable<? extendsObservableSource<? extends T>> sources, int maxConcurrency, int bufferSize)
You can combine the items emitted by multiple ObservableSources so that they appear as a single ObservableSource, by using themerge
method.
merge
does not operate by default on a particularScheduler
.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.T
- the common element base typesources
- the Iterable of ObservableSourcesmaxConcurrency
- the maximum number of ObservableSources that may be subscribed to concurrentlybufferSize
- the number of items to prefetch from each inner ObservableSourceIllegalArgumentException
- ifmaxConcurrent
is less than or equal to 0mergeDelayError(Iterable, int, int)
@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> mergeArray(int maxConcurrency, int bufferSize,ObservableSource<? extends T>... sources)
You can combine the items emitted by multiple ObservableSources so that they appear as a single ObservableSource, by using themerge
method.
mergeArray
does not operate by default on a particularScheduler
.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.T
- the common element base typesources
- the array of ObservableSourcesmaxConcurrency
- the maximum number of ObservableSources that may be subscribed to concurrentlybufferSize
- the number of items to prefetch from each inner ObservableSourceIllegalArgumentException
- ifmaxConcurrent
is less than or equal to 0mergeArrayDelayError(int, int, ObservableSource...)
@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> merge(Iterable<? extendsObservableSource<? extends T>> sources)
You can combine the items emitted by multiple ObservableSources so that they appear as a single ObservableSource, by using themerge
method.
merge
does not operate by default on a particularScheduler
.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.T
- the common element base typesources
- the Iterable of ObservableSourcesmergeDelayError(Iterable)
@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> merge(Iterable<? extendsObservableSource<? extends T>> sources, int maxConcurrency)
You can combine the items emitted by multiple ObservableSources so that they appear as a single ObservableSource, by using themerge
method.
merge
does not operate by default on a particularScheduler
.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.T
- the common element base typesources
- the Iterable of ObservableSourcesmaxConcurrency
- the maximum number of ObservableSources that may be subscribed to concurrentlyIllegalArgumentException
- ifmaxConcurrent
is less than or equal to 0mergeDelayError(Iterable, int)
@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> merge(ObservableSource<? extendsObservableSource<? extends T>> sources)
You can combine the items emitted by multiple ObservableSources so that they appear as a single ObservableSource, by using themerge
method.
merge
does not operate by default on a particularScheduler
.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.T
- the common element base typesources
- an ObservableSource that emits ObservableSourcessource
ObservableSourcemergeDelayError(ObservableSource)
@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> merge(ObservableSource<? extendsObservableSource<? extends T>> sources, int maxConcurrency)
You can combine the items emitted by multiple ObservableSources so that they appear as a single ObservableSource, by using themerge
method.
merge
does not operate by default on a particularScheduler
.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.T
- the common element base typesources
- an ObservableSource that emits ObservableSourcesmaxConcurrency
- the maximum number of ObservableSources that may be subscribed to concurrentlysource
ObservableSourceIllegalArgumentException
- ifmaxConcurrent
is less than or equal to 0mergeDelayError(ObservableSource, int)
@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> merge(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2)
You can combine items emitted by multiple ObservableSources so that they appear as a single ObservableSource, by using themerge
method.
merge
does not operate by default on a particularScheduler
.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.T
- the common element base typesource1
- an ObservableSource to be mergedsource2
- an ObservableSource to be mergedmergeDelayError(ObservableSource, ObservableSource)
@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> merge(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2,ObservableSource<? extends T> source3)
You can combine items emitted by multiple ObservableSources so that they appear as a single ObservableSource, by using themerge
method.
merge
does not operate by default on a particularScheduler
.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.T
- the common element base typesource1
- an ObservableSource to be mergedsource2
- an ObservableSource to be mergedsource3
- an ObservableSource to be mergedmergeDelayError(ObservableSource, ObservableSource, ObservableSource)
@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> merge(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2,ObservableSource<? extends T> source3,ObservableSource<? extends T> source4)
You can combine items emitted by multiple ObservableSources so that they appear as a single ObservableSource, by using themerge
method.
merge
does not operate by default on a particularScheduler
.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.T
- the common element base typesource1
- an ObservableSource to be mergedsource2
- an ObservableSource to be mergedsource3
- an ObservableSource to be mergedsource4
- an ObservableSource to be mergedmergeDelayError(ObservableSource, ObservableSource, ObservableSource, ObservableSource)
@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> mergeArray(ObservableSource<? extends T>... sources)
You can combine items emitted by multiple ObservableSources so that they appear as a single ObservableSource, by using themerge
method.
mergeArray
does not operate by default on a particularScheduler
.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.T
- the common element base typesources
- the array of ObservableSourcesmergeArrayDelayError(ObservableSource...)
@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> mergeDelayError(Iterable<? extendsObservableSource<? extends T>> sources)
This behaves likemerge(ObservableSource)
except that if any of the merged ObservableSources notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items.
Even if multiple merged ObservableSources sendonError
notifications,mergeDelayError
will only invoke theonError
method of its Observers once.
mergeDelayError
does not operate by default on a particularScheduler
.T
- the common element base typesources
- the Iterable of ObservableSources@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> mergeDelayError(Iterable<? extendsObservableSource<? extends T>> sources, int maxConcurrency, int bufferSize)
This behaves likemerge(ObservableSource)
except that if any of the merged ObservableSources notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items.
Even if multiple merged ObservableSources sendonError
notifications,mergeDelayError
will only invoke theonError
method of its Observers once.
mergeDelayError
does not operate by default on a particularScheduler
.T
- the common element base typesources
- the Iterable of ObservableSourcesmaxConcurrency
- the maximum number of ObservableSources that may be subscribed to concurrentlybufferSize
- the number of items to prefetch from each inner ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> mergeArrayDelayError(int maxConcurrency, int bufferSize,ObservableSource<? extends T>... sources)
This behaves likemerge(ObservableSource)
except that if any of the merged ObservableSources notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items.
Even if multiple merged ObservableSources sendonError
notifications,mergeDelayError
will only invoke theonError
method of its Observers once.
mergeArrayDelayError
does not operate by default on a particularScheduler
.T
- the common element base typesources
- the array of ObservableSourcesmaxConcurrency
- the maximum number of ObservableSources that may be subscribed to concurrentlybufferSize
- the number of items to prefetch from each inner ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> mergeDelayError(Iterable<? extendsObservableSource<? extends T>> sources, int maxConcurrency)
This behaves likemerge(ObservableSource)
except that if any of the merged ObservableSources notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items.
Even if multiple merged ObservableSources sendonError
notifications,mergeDelayError
will only invoke theonError
method of its Observers once.
mergeDelayError
does not operate by default on a particularScheduler
.T
- the common element base typesources
- the Iterable of ObservableSourcesmaxConcurrency
- the maximum number of ObservableSources that may be subscribed to concurrently@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> mergeDelayError(ObservableSource<? extendsObservableSource<? extends T>> sources)
This behaves likemerge(ObservableSource)
except that if any of the merged ObservableSources notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items.
Even if multiple merged ObservableSources sendonError
notifications,mergeDelayError
will only invoke theonError
method of its Observers once.
mergeDelayError
does not operate by default on a particularScheduler
.T
- the common element base typesources
- an ObservableSource that emits ObservableSourcessource
ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> mergeDelayError(ObservableSource<? extendsObservableSource<? extends T>> sources, int maxConcurrency)
This behaves likemerge(ObservableSource)
except that if any of the merged ObservableSources notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items.
Even if multiple merged ObservableSources sendonError
notifications,mergeDelayError
will only invoke theonError
method of its Observers once.
mergeDelayError
does not operate by default on a particularScheduler
.T
- the common element base typesources
- an ObservableSource that emits ObservableSourcesmaxConcurrency
- the maximum number of ObservableSources that may be subscribed to concurrentlysource
ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> mergeDelayError(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2)
This behaves likemerge(ObservableSource, ObservableSource)
except that if any of the merged ObservableSources notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items.
Even if both merged ObservableSources sendonError
notifications,mergeDelayError
will only invoke theonError
method of its Observers once.
mergeDelayError
does not operate by default on a particularScheduler
.T
- the common element base typesource1
- an ObservableSource to be mergedsource2
- an ObservableSource to be merged@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> mergeDelayError(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2,ObservableSource<? extends T> source3)
This behaves likemerge(ObservableSource, ObservableSource, ObservableSource)
except that if any of the merged ObservableSources notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items.
Even if multiple merged ObservableSources sendonError
notifications,mergeDelayError
will only invoke theonError
method of its Observers once.
mergeDelayError
does not operate by default on a particularScheduler
.T
- the common element base typesource1
- an ObservableSource to be mergedsource2
- an ObservableSource to be mergedsource3
- an ObservableSource to be merged@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> mergeDelayError(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2,ObservableSource<? extends T> source3,ObservableSource<? extends T> source4)
This behaves likemerge(ObservableSource, ObservableSource, ObservableSource, ObservableSource)
except that if any of the merged ObservableSources notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items.
Even if multiple merged ObservableSources sendonError
notifications,mergeDelayError
will only invoke theonError
method of its Observers once.
mergeDelayError
does not operate by default on a particularScheduler
.T
- the common element base typesource1
- an ObservableSource to be mergedsource2
- an ObservableSource to be mergedsource3
- an ObservableSource to be mergedsource4
- an ObservableSource to be merged@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> mergeArrayDelayError(ObservableSource<? extends T>... sources)
This behaves likemerge(ObservableSource)
except that if any of the merged ObservableSources notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items.
Even if multiple merged ObservableSources sendonError
notifications,mergeDelayError
will only invoke theonError
method of its Observers once.
mergeArrayDelayError
does not operate by default on a particularScheduler
.T
- the common element base typesources
- the Iterable of ObservableSources@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> never()
Observer
.This ObservableSource is useful primarily for testing purposes.
never
does not operate by default on a particularScheduler
.T
- the type of items (not) emitted by the ObservableSourceObserver
@CheckReturnValue@SchedulerSupport(value="none")public static Observable<Integer> range(int start, int count)
range
does not operate by default on a particularScheduler
.start
- the value of the first Integer in the sequencecount
- the number of sequential Integers to generateIllegalArgumentException
- ifcount
is less than zero, or ifstart
+count
− 1 exceedsInteger.MAX_VALUE
@CheckReturnValue@SchedulerSupport(value="none")public static Observable<Long> rangeLong(long start, long count)
rangeLong
does not operate by default on a particularScheduler
.start
- the value of the first Long in the sequencecount
- the number of sequential Longs to generateIllegalArgumentException
- ifcount
is less than zero, or ifstart
+count
− 1 exceedsLong.MAX_VALUE
@CheckReturnValue@SchedulerSupport(value="none")public static <T> Single<Boolean> sequenceEqual(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2)
sequenceEqual
does not operate by default on a particularScheduler
.T
- the type of items emitted by each ObservableSourcesource1
- the first ObservableSource to comparesource2
- the second ObservableSource to compare@CheckReturnValue@SchedulerSupport(value="none")public static <T> Single<Boolean> sequenceEqual(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2,BiPredicate<? super T,? super T> isEqual)
sequenceEqual
does not operate by default on a particularScheduler
.T
- the type of items emitted by each ObservableSourcesource1
- the first ObservableSource to comparesource2
- the second ObservableSource to compareisEqual
- a function used to compare items emitted by each ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T> Single<Boolean> sequenceEqual(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2,BiPredicate<? super T,? super T> isEqual, int bufferSize)
sequenceEqual
does not operate by default on a particularScheduler
.T
- the type of items emitted by each ObservableSourcesource1
- the first ObservableSource to comparesource2
- the second ObservableSource to compareisEqual
- a function used to compare items emitted by each ObservableSourcebufferSize
- the number of items to prefetch from the first and second source ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T> Single<Boolean> sequenceEqual(ObservableSource<? extends T> source1,ObservableSource<? extends T> source2, int bufferSize)
sequenceEqual
does not operate by default on a particularScheduler
.T
- the type of items emitted by each ObservableSourcesource1
- the first ObservableSource to comparesource2
- the second ObservableSource to comparebufferSize
- the number of items to prefetch from the first and second source ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> switchOnNext(ObservableSource<? extendsObservableSource<? extends T>> sources, int bufferSize)
switchOnNext
subscribes to an ObservableSource that emits ObservableSources. Each time it observes one of these emitted ObservableSources, the ObservableSource returned byswitchOnNext
begins emitting the items emitted by that ObservableSource. When a new ObservableSource is emitted,switchOnNext
stops emitting items from the earlier-emitted ObservableSource and begins emitting items from the new one.
The resulting ObservableSource completes if both the outer ObservableSource and the last inner ObservableSource, if any, complete. If the outer ObservableSource signals an onError, the inner ObservableSource is disposed and the error delivered in-sequence.
switchOnNext
does not operate by default on a particularScheduler
.T
- the item typesources
- the source ObservableSource that emits ObservableSourcesbufferSize
- the number of items to prefetch from the inner ObservableSources@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> switchOnNext(ObservableSource<? extendsObservableSource<? extends T>> sources)
switchOnNext
subscribes to an ObservableSource that emits ObservableSources. Each time it observes one of these emitted ObservableSources, the ObservableSource returned byswitchOnNext
begins emitting the items emitted by that ObservableSource. When a new ObservableSource is emitted,switchOnNext
stops emitting items from the earlier-emitted ObservableSource and begins emitting items from the new one.
The resulting ObservableSource completes if both the outer ObservableSource and the last inner ObservableSource, if any, complete. If the outer ObservableSource signals an onError, the inner ObservableSource is disposed and the error delivered in-sequence.
switchOnNext
does not operate by default on a particularScheduler
.T
- the item typesources
- the source ObservableSource that emits ObservableSources@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> switchOnNextDelayError(ObservableSource<? extendsObservableSource<? extends T>> sources)
switchOnNext
subscribes to an ObservableSource that emits ObservableSources. Each time it observes one of these emitted ObservableSources, the ObservableSource returned byswitchOnNext
begins emitting the items emitted by that ObservableSource. When a new ObservableSource is emitted,switchOnNext
stops emitting items from the earlier-emitted ObservableSource and begins emitting items from the new one.
The resulting ObservableSource completes if both the main ObservableSource and the last inner ObservableSource, if any, complete. If the main ObservableSource signals an onError, the termination of the last inner ObservableSource will emit that error as is or wrapped into a CompositeException along with the other possible errors the former inner ObservableSources signalled.
switchOnNextDelayError
does not operate by default on a particularScheduler
.T
- the item typesources
- the source ObservableSource that emits ObservableSources@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> switchOnNextDelayError(ObservableSource<? extendsObservableSource<? extends T>> sources, int prefetch)
switchOnNext
subscribes to an ObservableSource that emits ObservableSources. Each time it observes one of these emitted ObservableSources, the ObservableSource returned byswitchOnNext
begins emitting the items emitted by that ObservableSource. When a new ObservableSource is emitted,switchOnNext
stops emitting items from the earlier-emitted ObservableSource and begins emitting items from the new one.
The resulting ObservableSource completes if both the main ObservableSource and the last inner ObservableSource, if any, complete. If the main ObservableSource signals an onError, the termination of the last inner ObservableSource will emit that error as is or wrapped into a CompositeException along with the other possible errors the former inner ObservableSources signalled.
switchOnNextDelayError
does not operate by default on a particularScheduler
.T
- the item typesources
- the source ObservableSource that emits ObservableSourcesprefetch
- the number of items to prefetch from the inner ObservableSources@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public static Observable<Long> timer(long delay,TimeUnit unit)
0L
after a specified delay, and then completes.timer
operates by default on thecomputation
Scheduler
.delay
- the initial delay before emitting a single0L
unit
- time units to use fordelay
0L
after a specified delay, and then completes@CheckReturnValue@SchedulerSupport(value="custom")public static Observable<Long> timer(long delay,TimeUnit unit,Scheduler scheduler)
0L
after a specified delay, on a specified Scheduler, and then completes.Scheduler
this operator will use.delay
- the initial delay before emitting a single 0Lunit
- time units to use fordelay
scheduler
- theScheduler
to use for scheduling the item0L
after a specified delay, on a specified Scheduler, and then completesNullPointerException
- ifunit
is null, or ifscheduler
is null@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> unsafeCreate(ObservableSource<T> onSubscribe)
unsafeCreate
by default doesn't operate on any particularScheduler
.T
- the value type emittedonSubscribe
- the ObservableSource instance to wrap@CheckReturnValue@SchedulerSupport(value="none")public static <T,D> Observable<T> using(Callable<? extends D> resourceSupplier,Function<? super D,? extendsObservableSource<? extends T>> sourceSupplier,Consumer<? super D> disposer)
using
does not operate by default on a particularScheduler
.T
- the element type of the generated ObservableSourceD
- the type of the resource associated with the output sequenceresourceSupplier
- the factory function to create a resource object that depends on the ObservableSourcesourceSupplier
- the factory function to create an ObservableSourcedisposer
- the function that will dispose of the resource@CheckReturnValue@SchedulerSupport(value="none")public static <T,D> Observable<T> using(Callable<? extends D> resourceSupplier,Function<? super D,? extendsObservableSource<? extends T>> sourceSupplier,Consumer<? super D> disposer, boolean eager)
disposeEagerly
totrue
and a dispose() call does not occur before termination. Otherwise resource disposal will occur on a dispose() call. Eager disposal is particularly appropriate for a synchronous ObservableSource that reuses resources.disposeAction
will only be called once per subscription.using
does not operate by default on a particularScheduler
.T
- the element type of the generated ObservableSourceD
- the type of the resource associated with the output sequenceresourceSupplier
- the factory function to create a resource object that depends on the ObservableSourcesourceSupplier
- the factory function to create an ObservableSourcedisposer
- the function that will dispose of the resourceeager
- iftrue
then disposal will happen either on a dispose() call or just before emission of a terminal event (onComplete
oronError
).@CheckReturnValue@SchedulerSupport(value="none")public static <T> Observable<T> wrap(ObservableSource<T> source)
wrap
does not operate by default on a particularScheduler
.T
- the value typesource
- the source ObservableSource instanceNullPointerException
- if source is null@CheckReturnValue@SchedulerSupport(value="none")public static <T,R> Observable<R> zip(Iterable<? extendsObservableSource<? extends T>> sources,Function<? superObject[],? extends R> zipper)
zip
applies this function in strict sequence, so the first item emitted by the new ObservableSource will be the result of the function applied to the first item emitted by each of the source ObservableSources; the second item emitted by the new ObservableSource will be the result of the function applied to the second item emitted by each of those ObservableSources; and so forth.
The resultingObservableSource<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the source ObservableSource 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 callingdoOnComplete()
). 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.doOnDispose(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 withnew T[]
, the implementation of this operator has to create anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.
zip
does not operate by default on a particularScheduler
.T
- the common value typeR
- the zipped result typesources
- an Iterable of source ObservableSourceszipper
- a function that, when applied to an item emitted by each of the source ObservableSources, results in an item that will be emitted by the resulting ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T,R> Observable<R> zip(ObservableSource<? extendsObservableSource<? extends T>> sources,Function<? superObject[],? extends R> zipper)
zip
applies this function in strict sequence, so the first item emitted by the new ObservableSource will be the result of the function applied to the first item emitted by each of the ObservableSources emitted by the source ObservableSource; the second item emitted by the new ObservableSource will be the result of the function applied to the second item emitted by each of those ObservableSources; and so forth.
The resultingObservableSource<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the source ObservableSource 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 callingdoOnComplete()
). 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(just(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2)), (a) -> a)
action1
will be called butaction2
won't.doOnDispose(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 withnew T[]
, the implementation of this operator has to create anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.
zip
does not operate by default on a particularScheduler
.T
- the value type of the inner ObservableSourcesR
- the zipped result typesources
- an ObservableSource of source ObservableSourceszipper
- a function that, when applied to an item emitted by each of the ObservableSources emitted byws
, results in an item that will be emitted by the resulting ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T1,T2,R> Observable<R> zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,BiFunction<? super T1,? super T2,? extends R> zipper)
zip
applies this function in strict sequence, so the first item emitted by the new ObservableSource 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 new ObservableSource will be the result of the function applied to the second item emitted byo1
and the second item emitted byo2
; and so forth.
The resultingObservableSource<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the source ObservableSource 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 callingdoOnComplete()
). 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.doOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.zip
does not operate by default on a particularScheduler
.T1
- the value type of the first sourceT2
- the value type of the second sourceR
- the zipped result typesource1
- the first source ObservableSourcesource2
- a second source ObservableSourcezipper
- a function that, when applied to an item emitted by each of the source ObservableSources, results in an item that will be emitted by the resulting ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T1,T2,R> Observable<R> zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,BiFunction<? super T1,? super T2,? extends R> zipper, boolean delayError)
zip
applies this function in strict sequence, so the first item emitted by the new ObservableSource 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 new ObservableSource will be the result of the function applied to the second item emitted byo1
and the second item emitted byo2
; and so forth.
The resultingObservableSource<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the source ObservableSource 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 callingdoOnComplete()
). 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.doOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.zip
does not operate by default on a particularScheduler
.T1
- the value type of the first sourceT2
- the value type of the second sourceR
- the zipped result typesource1
- the first source ObservableSourcesource2
- a second source ObservableSourcezipper
- a function that, when applied to an item emitted by each of the source ObservableSources, results in an item that will be emitted by the resulting ObservableSourcedelayError
- delay errors from any of the source ObservableSources till the other terminates@CheckReturnValue@SchedulerSupport(value="none")public static <T1,T2,R> Observable<R> zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,BiFunction<? super T1,? super T2,? extends R> zipper, boolean delayError, int bufferSize)
zip
applies this function in strict sequence, so the first item emitted by the new ObservableSource 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 new ObservableSource will be the result of the function applied to the second item emitted byo1
and the second item emitted byo2
; and so forth.
The resultingObservableSource<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the source ObservableSource 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 callingdoOnComplete()
). 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.doOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.zip
does not operate by default on a particularScheduler
.T1
- the value type of the first sourceT2
- the value type of the second sourceR
- the zipped result typesource1
- the first source ObservableSourcesource2
- a second source ObservableSourcezipper
- a function that, when applied to an item emitted by each of the source ObservableSources, results in an item that will be emitted by the resulting ObservableSourcedelayError
- delay errors from any of the source ObservableSources till the other terminatesbufferSize
- the number of elements to prefetch from each source ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T1,T2,T3,R> Observable<R> zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,Function3<? super T1,? super T2,? super T3,? extends R> zipper)
zip
applies this function in strict sequence, so the first item emitted by the new ObservableSource 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 new ObservableSource 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 resultingObservableSource<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the source ObservableSource 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 callingdoOnComplete()
). 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.doOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.zip
does not operate by default on a particularScheduler
.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 typesource1
- the first source ObservableSourcesource2
- a second source ObservableSourcesource3
- a third source ObservableSourcezipper
- a function that, when applied to an item emitted by each of the source ObservableSources, results in an item that will be emitted by the resulting ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T1,T2,T3,T4,R> Observable<R> zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,Function4<? super T1,? super T2,? super T3,? super T4,? extends R> zipper)
zip
applies this function in strict sequence, so the first item emitted by the new ObservableSource 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 new ObservableSource will be the result of the function applied to the second item emitted by each of those ObservableSources; and so forth.
The resultingObservableSource<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the source ObservableSource 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 callingdoOnComplete()
). 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.doOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.zip
does not operate by default on a particularScheduler
.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 typesource1
- the first source ObservableSourcesource2
- a second source ObservableSourcesource3
- a third source ObservableSourcesource4
- a fourth source ObservableSourcezipper
- a function that, when applied to an item emitted by each of the source ObservableSources, results in an item that will be emitted by the resulting ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,R> Observable<R> zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,Function5<? super T1,? super T2,? super T3,? super T4,? super T5,? extends R> zipper)
zip
applies this function in strict sequence, so the first item emitted by the new ObservableSource 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 new ObservableSource will be the result of the function applied to the second item emitted by each of those ObservableSources; and so forth.
The resultingObservableSource<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the source ObservableSource 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 callingdoOnComplete()
). 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.doOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.zip
does not operate by default on a particularScheduler
.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 typesource1
- the first source ObservableSourcesource2
- a second source ObservableSourcesource3
- a third source ObservableSourcesource4
- a fourth source ObservableSourcesource5
- a fifth source ObservableSourcezipper
- a function that, when applied to an item emitted by each of the source ObservableSources, results in an item that will be emitted by the resulting ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,T6,R> Observable<R> zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,ObservableSource<? extends T6> source6,Function6<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? extends R> zipper)
zip
applies this function in strict sequence, so the first item emitted by the new ObservableSource will be the result of the function applied to the first item emitted by each source ObservableSource, the second item emitted by the new ObservableSource will be the result of the function applied to the second item emitted by each of those ObservableSources, and so forth.
The resultingObservableSource<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the source ObservableSource 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 callingdoOnComplete()
). 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.doOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.zip
does not operate by default on a particularScheduler
.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 typesource1
- the first source ObservableSourcesource2
- a second source ObservableSourcesource3
- a third source ObservableSourcesource4
- a fourth source ObservableSourcesource5
- a fifth source ObservableSourcesource6
- a sixth source ObservableSourcezipper
- a function that, when applied to an item emitted by each of the source ObservableSources, results in an item that will be emitted by the resulting ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,T6,T7,R> Observable<R> zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,ObservableSource<? extends T6> source6,ObservableSource<? extends T7> source7,Function7<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? extends R> zipper)
zip
applies this function in strict sequence, so the first item emitted by the new ObservableSource will be the result of the function applied to the first item emitted by each source ObservableSource, the second item emitted by the new ObservableSource will be the result of the function applied to the second item emitted by each of those ObservableSources, and so forth.
The resultingObservableSource<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the source ObservableSource 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 callingdoOnComplete()
). 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.doOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.zip
does not operate by default on a particularScheduler
.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 typesource1
- the first source ObservableSourcesource2
- a second source ObservableSourcesource3
- a third source ObservableSourcesource4
- a fourth source ObservableSourcesource5
- a fifth source ObservableSourcesource6
- a sixth source ObservableSourcesource7
- a seventh source ObservableSourcezipper
- a function that, when applied to an item emitted by each of the source ObservableSources, results in an item that will be emitted by the resulting ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,T6,T7,T8,R> Observable<R> zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,ObservableSource<? extends T6> source6,ObservableSource<? extends T7> source7,ObservableSource<? extends T8> source8,Function8<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? extends R> zipper)
zip
applies this function in strict sequence, so the first item emitted by the new ObservableSource will be the result of the function applied to the first item emitted by each source ObservableSource, the second item emitted by the new ObservableSource will be the result of the function applied to the second item emitted by each of those ObservableSources, and so forth.
The resultingObservableSource<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the source ObservableSource 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 callingdoOnComplete()
). 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.doOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.zip
does not operate by default on a particularScheduler
.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 typesource1
- the first source ObservableSourcesource2
- a second source ObservableSourcesource3
- a third source ObservableSourcesource4
- a fourth source ObservableSourcesource5
- a fifth source ObservableSourcesource6
- a sixth source ObservableSourcesource7
- a seventh source ObservableSourcesource8
- an eighth source ObservableSourcezipper
- a function that, when applied to an item emitted by each of the source ObservableSources, results in an item that will be emitted by the resulting ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> Observable<R> zip(ObservableSource<? extends T1> source1,ObservableSource<? extends T2> source2,ObservableSource<? extends T3> source3,ObservableSource<? extends T4> source4,ObservableSource<? extends T5> source5,ObservableSource<? extends T6> source6,ObservableSource<? extends T7> source7,ObservableSource<? extends T8> source8,ObservableSource<? extends T9> source9,Function9<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? super T9,? extends R> zipper)
zip
applies this function in strict sequence, so the first item emitted by the new ObservableSource will be the result of the function applied to the first item emitted by each source ObservableSource, the second item emitted by the new ObservableSource will be the result of the function applied to the second item emitted by each of those ObservableSources, and so forth.
The resultingObservableSource<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the source ObservableSource 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 callingdoOnComplete()
). 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.doOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.zip
does not operate by default on a particularScheduler
.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 typesource1
- the first source ObservableSourcesource2
- a second source ObservableSourcesource3
- a third source ObservableSourcesource4
- a fourth source ObservableSourcesource5
- a fifth source ObservableSourcesource6
- a sixth source ObservableSourcesource7
- a seventh source ObservableSourcesource8
- an eighth source ObservableSourcesource9
- a ninth source ObservableSourcezipper
- a function that, when applied to an item emitted by each of the source ObservableSources, results in an item that will be emitted by the resulting ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T,R> Observable<R> zipArray(Function<? superObject[],? extends R> zipper, boolean delayError, int bufferSize,ObservableSource<? extends T>... sources)
zip
applies this function in strict sequence, so the first item emitted by the new ObservableSource will be the result of the function applied to the first item emitted by each of the source ObservableSources; the second item emitted by the new ObservableSource will be the result of the function applied to the second item emitted by each of those ObservableSources; and so forth.
The resultingObservableSource<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the source ObservableSource 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 callingdoOnComplete()
). 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.doOnDispose(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 withnew T[]
, the implementation of this operator has to create anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.
zipArray
does not operate by default on a particularScheduler
.T
- the common element typeR
- the result typesources
- an array of source ObservableSourceszipper
- a function that, when applied to an item emitted by each of the source ObservableSources, results in an item that will be emitted by the resulting ObservableSourcedelayError
- delay errors signalled by any of the source ObservableSource until all ObservableSources terminatebufferSize
- the number of elements to prefetch from each source ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public static <T,R> Observable<R> zipIterable(Iterable<? extendsObservableSource<? extends T>> sources,Function<? superObject[],? extends R> zipper, boolean delayError, int bufferSize)
zip
applies this function in strict sequence, so the first item emitted by the new ObservableSource will be the result of the function applied to the first item emitted by each of the source ObservableSources; the second item emitted by the new ObservableSource will be the result of the function applied to the second item emitted by each of those ObservableSources; and so forth.
The resultingObservableSource<R>
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the source ObservableSource 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 callingdoOnComplete()
). 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.doOnDispose(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 withnew T[]
, the implementation of this operator has to create anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.
zipIterable
does not operate by default on a particularScheduler
.T
- the common source value typeR
- the zipped result typesources
- an Iterable of source ObservableSourceszipper
- a function that, when applied to an item emitted by each of the source ObservableSources, results in an item that will be emitted by the resulting ObservableSourcedelayError
- delay errors signalled by any of the source ObservableSource until all ObservableSources terminatebufferSize
- the number of elements to prefetch from each source ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final Single<Boolean> all(Predicate<? superT> predicate)
all
does not operate by default on a particularScheduler
.predicate
- a function that evaluates an item and returns a Booleantrue
if all items emitted by the source ObservableSource satisfy the predicate; otherwise,false
@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> ambWith(ObservableSource<? extendsT> other)
ambWith
does not operate by default on a particularScheduler
.other
- an ObservableSource competing to react first. A subscription to this provided source will occur after subscribing to the current source.@CheckReturnValue@SchedulerSupport(value="none")public final Single<Boolean> any(Predicate<? superT> predicate)
true
if any item emitted by the source ObservableSource satisfies a specified condition, otherwisefalse
.Note: this always emitsfalse
if the source ObservableSource is empty. In Rx.Net this is theany
Observer but we renamed it in RxJava to better match Java naming idioms.
any
does not operate by default on a particularScheduler
.predicate
- the condition to test items emitted by the source ObservableSourcepredicate
@CheckReturnValue@SchedulerSupport(value="none")public final <R> R as(@NonNullObservableConverter<T,? extends R> converter)
This allows fluent conversion to any other type.
as
does not operate by default on a particularScheduler
.History: 2.1.7 - experimental
R
- the resulting object typeconverter
- the function that receives the current Observable instance and returns a valueNullPointerException
- if converter is null@CheckReturnValue@SchedulerSupport(value="none")public final T blockingFirst()
Observable
, or throwsNoSuchElementException
if it emits no items.blockingFirst
does not operate by default on a particularScheduler
.Observable
NoSuchElementException
- if thisObservable
emits no items@CheckReturnValue@SchedulerSupport(value="none")public final T blockingFirst(T defaultItem)
Observable
, or a default value if it emits no items.blockingFirst
does not operate by default on a particularScheduler
.defaultItem
- a default value to return if thisObservable
emits no itemsObservable
, or the default value if it emits no items@SchedulerSupport(value="none")public final void blockingForEach(Consumer<? superT> onNext)
Observable
in a blocking fashion and invokes the givenConsumer
with each upstream item on thecurrent thread until the upstream terminates.Note: the method will only return if the upstream terminates or the current thread is interrupted.
This method executes theConsumer
on the current thread whilesubscribe(Consumer)
executes the consumer on the original caller thread of the sequence.
blockingForEach
does not operate by default on a particularScheduler
.Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.onNext
- theConsumer
to invoke for each item emitted by theObservable
RuntimeException
- if an error occurssubscribe(Consumer)
@CheckReturnValue@SchedulerSupport(value="none")public final Iterable<T> blockingIterable()
Observable
into anIterable
.blockingIterable
does not operate by default on a particularScheduler
.Iterable
version of thisObservable
@CheckReturnValue@SchedulerSupport(value="none")public final Iterable<T> blockingIterable(int bufferSize)
Observable
into anIterable
.blockingIterable
does not operate by default on a particularScheduler
.bufferSize
- the number of items to prefetch from the current ObservableIterable
version of thisObservable
@CheckReturnValue@SchedulerSupport(value="none")public final T blockingLast()
Observable
, or throwsNoSuchElementException
if thisObservable
emits no items.blockingLast
does not operate by default on a particularScheduler
.Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.Observable
NoSuchElementException
- if thisObservable
emits no items@CheckReturnValue@SchedulerSupport(value="none")public final T blockingLast(T defaultItem)
Observable
, or a default value if it emits no items.blockingLast
does not operate by default on a particularScheduler
.Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.defaultItem
- a default value to return if thisObservable
emits no itemsObservable
, or the default value if it emits no items@CheckReturnValue@SchedulerSupport(value="none")public final Iterable<T> blockingLatest()
Iterable
that returns the latest item emitted by thisObservable
, waiting if necessary for one to become available. If thisObservable
produces items faster thanIterator.next
takes them,onNext
events might be skipped, butonError
oronComplete
events are not.
Note also that anonNext
directly followed byonComplete
might hide theonNext
event.
blockingLatest
does not operate by default on a particularScheduler
.Observable
@CheckReturnValue@SchedulerSupport(value="none")public final Iterable<T> blockingMostRecent(T initialValue)
Iterable
that always returns the item most recently emitted by thisObservable
.blockingMostRecent
does not operate by default on a particularScheduler
.initialValue
- the initial value that theIterable
sequence will yield if thisObservable
has not yet emitted an itemIterable
that on each iteration returns the item that thisObservable
has most recently emitted@CheckReturnValue@SchedulerSupport(value="none")public final Iterable<T> blockingNext()
Iterable
that blocks until thisObservable
emits another item, then returns that item.blockingNext
does not operate by default on a particularScheduler
.Iterable
that blocks upon each iteration until thisObservable
emits a new item, whereupon the Iterable returns that item@CheckReturnValue@SchedulerSupport(value="none")public final T blockingSingle()
Observable
completes after emitting a single item, return that item, otherwise throw aNoSuchElementException
.blockingSingle
does not operate by default on a particularScheduler
.Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.Observable
@CheckReturnValue@SchedulerSupport(value="none")public final T blockingSingle(T defaultItem)
Observable
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.blockingSingle
does not operate by default on a particularScheduler
.Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.defaultItem
- a default value to return if thisObservable
emits no itemsObservable
, or the default value if it emits no items@CheckReturnValue@SchedulerSupport(value="none")public final Future<T> toFuture()
Future
representing the only value emitted by thisObservable
. If theObservable
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 theObservable
may emit more than one item, useObservable.toList().toFuture()
.
toFuture
does not operate by default on a particularScheduler
.Future
that expects a single item to be emitted by thisObservable
@SchedulerSupport(value="none")public final void blockingSubscribe()
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.
blockingSubscribe
does not operate by default on a particularScheduler
.@SchedulerSupport(value="none")public final void blockingSubscribe(Consumer<? superT> onNext)
If theObservable
emits an error, it is wrapped into anOnErrorNotImplementedException
and routed to the RxJavaPlugins.onError 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.
blockingSubscribe
does not operate by default on a particularScheduler
.onNext
- the callback action for each source valueblockingSubscribe(Consumer, Consumer)
,blockingSubscribe(Consumer, Consumer, Action)
@SchedulerSupport(value="none")public final void blockingSubscribe(Consumer<? superT> onNext,Consumer<? superThrowable> onError)
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.
blockingSubscribe
does not operate by default on a particularScheduler
.onNext
- the callback action for each source valueonError
- the callback action for an error eventblockingSubscribe(Consumer, Consumer, Action)
@SchedulerSupport(value="none")public final void blockingSubscribe(Consumer<? superT> onNext,Consumer<? superThrowable> onError,Action onComplete)
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.
blockingSubscribe
does not operate by default on a particularScheduler
.onNext
- the callback action for each source valueonError
- the callback action for an error eventonComplete
- the callback action for the completion event.@SchedulerSupport(value="none")public final void blockingSubscribe(Observer<? superT> observer)
Observer
methodson the current thread. Note that calling this method will block the caller thread until the upstream terminates normally, with an error or theObserver
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.
blockingSubscribe
does not operate by default on a particularScheduler
.observer
- theObserver
instance to forward events and calls to in the current thread@CheckReturnValue@SchedulerSupport(value="none")public final Observable<List<T>> buffer(int count)
count
items. When the source ObservableSource completes, the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource. Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.buffer
does not operate by default on a particularScheduler
.count
- the maximum number of items in each buffer before it should be emittedcount
items from the source ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final Observable<List<T>> buffer(int count, int skip)
skip
items, each containingcount
items. When the source ObservableSource completes, the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource. Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.buffer
does not operate by default on a particularScheduler
.count
- the maximum size of each buffer before it should be emittedskip
- how many items emitted by the source ObservableSource should be skipped before starting a new buffer. Note that whenskip
andcount
are equal, this is the same operation asbuffer(int)
.skip
item from the source ObservableSource and containing at mostcount
items@CheckReturnValue@SchedulerSupport(value="none")public final <U extendsCollection<? superT>> Observable<U> buffer(int count, int skip,Callable<U> bufferSupplier)
skip
items, each containingcount
items. When the source ObservableSource completes, the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource. Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.buffer
does not operate by default on a particularScheduler
.U
- the collection subclass type to buffer intocount
- the maximum size of each buffer before it should be emittedskip
- how many items emitted by the source ObservableSource 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 bufferskip
item from the source ObservableSource and containing at mostcount
items@CheckReturnValue@SchedulerSupport(value="none")public final <U extendsCollection<? superT>> Observable<U> buffer(int count,Callable<U> bufferSupplier)
count
items. When the source ObservableSource completes, the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource. Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.buffer
does not operate by default on a particularScheduler
.U
- the collection subclass type to buffer intocount
- 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 buffercount
items from the source ObservableSource@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<List<T>> buffer(long timespan, long timeskip,TimeUnit unit)
timeskip
argument. It emits each buffer after a fixed timespan, specified by thetimespan
argument. When the source ObservableSource completes, the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource. Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.buffer
operates by default on thecomputation
Scheduler
.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@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<List<T>> buffer(long timespan, long timeskip,TimeUnit unit,Scheduler scheduler)
timeskip
argument, and on the specifiedscheduler
. It emits each buffer after a fixed timespan, specified by thetimespan
argument. When the source ObservableSource completes, the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource. Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.Scheduler
this operator will use.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@CheckReturnValue@SchedulerSupport(value="custom")public final <U extendsCollection<? superT>> Observable<U> buffer(long timespan, long timeskip,TimeUnit unit,Scheduler scheduler,Callable<U> bufferSupplier)
timeskip
argument, and on the specifiedscheduler
. It emits each buffer after a fixed timespan, specified by thetimespan
argument. When the source ObservableSource completes, the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource. Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.Scheduler
this operator will use.U
- the collection subclass type to buffer intotimespan
- 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@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<List<T>> buffer(long timespan,TimeUnit unit)
timespan
argument. When the source ObservableSource completes, the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource. Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.buffer
operates by default on thecomputation
Scheduler
.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@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<List<T>> buffer(long timespan,TimeUnit unit, int count)
timespan
argument or a maximum size specified by thecount
argument (whichever is reached first). When the source ObservableSource completes, the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource. Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.buffer
operates by default on thecomputation
Scheduler
.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@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<List<T>> buffer(long timespan,TimeUnit unit,Scheduler scheduler, int count)
timespan
argument as measured on the specifiedscheduler
, or a maximum size specified by thecount
argument (whichever is reached first). When the source ObservableSource completes, the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource. Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.Scheduler
this operator will use.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@CheckReturnValue@SchedulerSupport(value="custom")public final <U extendsCollection<? superT>> Observable<U> buffer(long timespan,TimeUnit unit,Scheduler scheduler, int count,Callable<U> bufferSupplier, boolean restartTimerOnMaxSize)
timespan
argument as measured on the specifiedscheduler
, or a maximum size specified by thecount
argument (whichever is reached first). When the source ObservableSource completes, the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource. Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.Scheduler
this operator will use.U
- the collection subclass type to buffer intotimespan
- 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
- if true the time window is restarted when the max capacity of the current buffer is reached@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<List<T>> buffer(long timespan,TimeUnit unit,Scheduler scheduler)
timespan
argument and on the specifiedscheduler
. When the source ObservableSource completes, the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource. Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.Scheduler
this operator will use.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@CheckReturnValue@SchedulerSupport(value="none")public final <TOpening,TClosing> Observable<List<T>> buffer(ObservableSource<? extends TOpening> openingIndicator,Function<? super TOpening,? extendsObservableSource<? extends TClosing>> closingIndicator)
openingIndicator
ObservableSource emits an item, and closes when the ObservableSource returned fromclosingIndicator
emits an item. If any of the source ObservableSource,openingIndicator
orclosingIndicator
issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.buffer
does not operate by default on a particularScheduler
.TOpening
- the element type of the buffer-opening ObservableSourceTClosing
- the element type of the individual buffer-closing ObservableSourcesopeningIndicator
- the ObservableSource that, when it emits an item, causes a new buffer to be createdclosingIndicator
- theFunction
that is used to produce an ObservableSource for every buffer created. When this ObservableSource emits an item, the associated buffer is emitted.@CheckReturnValue@SchedulerSupport(value="none")public final <TOpening,TClosing,U extendsCollection<? superT>> Observable<U> buffer(ObservableSource<? extends TOpening> openingIndicator,Function<? super TOpening,? extendsObservableSource<? extends TClosing>> closingIndicator,Callable<U> bufferSupplier)
openingIndicator
ObservableSource emits an item, and closes when the ObservableSource returned fromclosingIndicator
emits an item. If any of the source ObservableSource,openingIndicator
orclosingIndicator
issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.buffer
does not operate by default on a particularScheduler
.U
- the collection subclass type to buffer intoTOpening
- the element type of the buffer-opening ObservableSourceTClosing
- the element type of the individual buffer-closing ObservableSourcesopeningIndicator
- the ObservableSource that, when it emits an item, causes a new buffer to be createdclosingIndicator
- theFunction
that is used to produce an ObservableSource for every buffer created. When this ObservableSource 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@CheckReturnValue@SchedulerSupport(value="none")public final <B> Observable<List<T>> buffer(ObservableSource<B> boundary)
Completion of either the source or the boundary ObservableSource causes the returned ObservableSource to emit the latest buffer and complete. If either the source ObservableSource or the boundary ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.
buffer
does not operate by default on a particularScheduler
.B
- the boundary value type (ignored)boundary
- the boundary ObservableSourcebuffer(ObservableSource, int)
,ReactiveX operators documentation: Buffer@CheckReturnValue@SchedulerSupport(value="none")public final <B> Observable<List<T>> buffer(ObservableSource<B> boundary, int initialCapacity)
Completion of either the source or the boundary ObservableSource causes the returned ObservableSource to emit the latest buffer and complete. If either the source ObservableSource or the boundary ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.
buffer
does not operate by default on a particularScheduler
.B
- the boundary value type (ignored)boundary
- the boundary ObservableSourceinitialCapacity
- the initial capacity of each buffer chunkbuffer(ObservableSource)
@CheckReturnValue@SchedulerSupport(value="none")public final <B,U extendsCollection<? superT>> Observable<U> buffer(ObservableSource<B> boundary,Callable<U> bufferSupplier)
Completion of either the source or the boundary ObservableSource causes the returned ObservableSource to emit the latest buffer and complete. If either the source ObservableSource or the boundary ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.
buffer
does not operate by default on a particularScheduler
.U
- the collection subclass type to buffer intoB
- the boundary value type (ignored)boundary
- the boundary ObservableSourcebufferSupplier
- a factory function that returns an instance of the collection subclass to be used and returned as the bufferbuffer(ObservableSource, int)
,ReactiveX operators documentation: Buffer@CheckReturnValue@SchedulerSupport(value="none")public final <B> Observable<List<T>> buffer(Callable<? extendsObservableSource<B>> boundarySupplier)
boundarySupplier
emits an item. If either the sourceObservableSource
or the boundaryObservableSource
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.
buffer
does not operate by default on a particularScheduler
.B
- the value type of the boundary-providing ObservableSourceboundarySupplier
- aCallable
that produces an ObservableSource that governs the boundary between buffers. Whenever the suppliedObservableSource
emits an item,buffer
emits the current buffer and begins to fill a new oneclosingIndicator
argument emits an item@CheckReturnValue@SchedulerSupport(value="none")public final <B,U extendsCollection<? superT>> Observable<U> buffer(Callable<? extendsObservableSource<B>> boundarySupplier,Callable<U> bufferSupplier)
boundarySupplier
emits an item. If either the sourceObservableSource
or the boundaryObservableSource
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.
buffer
does not operate by default on a particularScheduler
.U
- the collection subclass type to buffer intoB
- the value type of the boundary-providing ObservableSourceboundarySupplier
- aCallable
that produces an ObservableSource that governs the boundary between buffers. Whenever the suppliedObservableSource
emits an item,buffer
emits the current buffer and begins to fill a new onebufferSupplier
- a factory function that returns an instance of the collection subclass to be used and returned as the bufferclosingIndicator
argument emits an item@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> cache()
This is useful when you want an ObservableSource to cache responses and you can't control the subscribe/dispose behavior of all theObserver
s.
The operator subscribes only when the first downstream subscriber subscribes and maintains a single subscription towards this ObservableSource. 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 thecache
Observer so be careful not to use this Observer on ObservableSources 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 of cache().
AtomicBoolean shouldStop = new AtomicBoolean(); source.takeUntil(v -> shouldStop.get()) .cache() .takeUntil(v -> shouldStop.get()) .subscribe(...);
Since the operator doesn't allow clearing the cached values either, the possible workaround is to forget all references to it viaonTerminateDetach()
applied along with the previous workaround: AtomicBoolean shouldStop = new AtomicBoolean(); source.takeUntil(v -> shouldStop.get()) .onTerminateDetach() .cache() .takeUntil(v -> shouldStop.get()) .onTerminateDetach() .subscribe(...);
cache
does not operate by default on a particularScheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> cacheWithInitialCapacity(int initialCapacity)
This is useful when you want an ObservableSource to cache responses and you can't control the subscribe/dispose behavior of all theObserver
s.
The operator subscribes only when the first downstream subscriber subscribes and maintains a single subscription towards this ObservableSource. 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 thecache
Observer so be careful not to use this Observer on ObservableSources 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 of cache().
AtomicBoolean shouldStop = new AtomicBoolean(); source.takeUntil(v -> shouldStop.get()) .cache() .takeUntil(v -> shouldStop.get()) .subscribe(...);
Since the operator doesn't allow clearing the cached values either, the possible workaround is to forget all references to it viaonTerminateDetach()
applied along with the previous workaround: AtomicBoolean shouldStop = new AtomicBoolean(); source.takeUntil(v -> shouldStop.get()) .onTerminateDetach() .cache() .takeUntil(v -> shouldStop.get()) .onTerminateDetach() .subscribe(...);
cacheWithInitialCapacity
does not operate by default on a particularScheduler
.Note: The capacity hint is not an upper bound on cache size. For that, considerreplay(int)
in combination withConnectableObservable.autoConnect()
or similar.
initialCapacity
- hint for number of items to cache (for optimizing underlying data structure)@CheckReturnValue@SchedulerSupport(value="none")public final <U> Observable<U> cast(Class<U> clazz)
cast
does not operate by default on a particularScheduler
.U
- the output value type cast toclazz
- the target class type thatcast
will cast the items emitted by the source ObservableSource into before emitting them from the resulting ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final <U> Single<U> collect(Callable<? extends U> initialValueSupplier,BiConsumer<? super U,? superT> collector)
This is a simplified version ofreduce
that does not need to return the state on each pass.
Note that this operator requires the upstream to signalonComplete
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
.
collect
does not operate by default on a particularScheduler
.U
- the accumulator and output typeinitialValueSupplier
- the mutable data structure that will collect the itemscollector
- a function that accepts thestate
and an emitted item, and modifiesstate
accordingly@CheckReturnValue@SchedulerSupport(value="none")public final <U> Single<U> collectInto(U initialValue,BiConsumer<? super U,? superT> collector)
This is a simplified version ofreduce
that does not need to return the state on each pass.
Note that this operator requires the upstream to signalonComplete
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
.
collectInto
does not operate by default on a particularScheduler
.U
- the accumulator and output typeinitialValue
- the mutable data structure that will collect the itemscollector
- a function that accepts thestate
and an emitted item, and modifiesstate
accordingly@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> compose(ObservableTransformer<? superT,? extends R> composer)
This method operates on the ObservableSource itself whereaslift(io.reactivex.ObservableOperator<? extends R, ? super T>)
operates on the ObservableSource's Observers.
If the operator you are creating is designed to act on the individual items emitted by a source ObservableSource, uselift(io.reactivex.ObservableOperator<? extends R, ? super T>)
. If your operator is designed to transform the source ObservableSource as a whole (for instance, by applying a particular set of existing RxJava operators to it) usecompose
.
compose
does not operate by default on a particularScheduler
.R
- the value type of the output ObservableSourcecomposer
- implements the function that transforms the source ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMap(Function<? superT,? extendsObservableSource<? extends R>> mapper)
concatMap
does not operate by default on a particularScheduler
.R
- the type of the inner ObservableSource sources and thus the output typemapper
- a function that, when applied to an item emitted by the source ObservableSource, returns an ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMap(Function<? superT,? extendsObservableSource<? extends R>> mapper, int prefetch)
concatMap
does not operate by default on a particularScheduler
.R
- the type of the inner ObservableSource sources and thus the output typemapper
- a function that, when applied to an item emitted by the source ObservableSource, returns an ObservableSourceprefetch
- the number of elements to prefetch from the current Observable@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMapDelayError(Function<? superT,? extendsObservableSource<? extends R>> mapper)
concatMapDelayError
does not operate by default on a particularScheduler
.R
- the result value typemapper
- the function that maps the items of this ObservableSource into the inner ObservableSources.@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMapDelayError(Function<? superT,? extendsObservableSource<? extends R>> mapper, int prefetch, boolean tillTheEnd)
concatMapDelayError
does not operate by default on a particularScheduler
.R
- the result value typemapper
- the function that maps the items of this ObservableSource into the inner ObservableSources.prefetch
- the number of elements to prefetch from the current ObservabletillTheEnd
- if true, all errors from the outer and inner ObservableSource sources are delayed until the end, if false, an error from the main source is signalled when the current ObservableSource source terminates@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMapEager(Function<? superT,? extendsObservableSource<? extends R>> mapper)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.
Scheduler
.R
- the value typemapper
- the function that maps a sequence of values into a sequence of ObservableSources that will be eagerly concatenated@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMapEager(Function<? superT,? extendsObservableSource<? extends R>> mapper, int maxConcurrency, int prefetch)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.
Scheduler
.R
- the value typemapper
- the function that maps a sequence of values into a sequence of ObservableSources that will be eagerly concatenatedmaxConcurrency
- the maximum number of concurrent subscribed ObservableSourcesprefetch
- hints about the number of expected values from each inner ObservableSource, must be positive@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMapEagerDelayError(Function<? superT,? extendsObservableSource<? extends R>> mapper, boolean tillTheEnd)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.
Scheduler
.R
- the value typemapper
- the function that maps a sequence of values into a sequence of ObservableSources that will be eagerly concatenatedtillTheEnd
- if true, all errors from the outer and inner ObservableSource sources are delayed until the end, if false, an error from the main source is signalled when the current ObservableSource source terminates@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMapEagerDelayError(Function<? superT,? extendsObservableSource<? extends R>> mapper, int maxConcurrency, int prefetch, boolean tillTheEnd)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.
Scheduler
.R
- the value typemapper
- the function that maps a sequence of values into a sequence of ObservableSources that will be eagerly concatenatedmaxConcurrency
- the maximum number of concurrent subscribed ObservableSourcesprefetch
- the number of elements to prefetch from each source ObservableSourcetillTheEnd
- if true, exceptions from the current Observable and all the inner ObservableSources are delayed until all of them terminate, if false, exception from the current Observable is delayed until the currently running ObservableSource terminates@CheckReturnValue@SchedulerSupport(value="none")public final Completable concatMapCompletable(Function<? superT,? extendsCompletableSource> mapper)
concatMapCompletable
does not operate by default on a particularScheduler
.History: 2.1.6 - experimental
mapper
- a function that, when applied to an item emitted by the source ObservableSource, returns a CompletableSourceonComplete
when the upstream and all CompletableSources complete@CheckReturnValue@SchedulerSupport(value="none")public final Completable concatMapCompletable(Function<? superT,? extendsCompletableSource> mapper, int capacityHint)
concatMapCompletable
does not operate by default on a particularScheduler
.History: 2.1.6 - experimental
mapper
- a function that, when applied to an item emitted by the source ObservableSource, returns a CompletableSourcecapacityHint
- the number of upstream items expected to be buffered until the current CompletableSource, mapped from the current item, completes.onComplete
when the upstream and all CompletableSources complete@CheckReturnValue@SchedulerSupport(value="none")public final Completable concatMapCompletableDelayError(Function<? superT,? extendsCompletableSource> mapper)
CompletableSource
s and subscribes to them one after the other terminates, delaying all errors till both thisObservable
and all innerCompletableSource
s terminate.concatMapCompletableDelayError
does not operate by default on a particularScheduler
.History: 2.1.11 - experimental
mapper
- the function called with the upstream item and should return aCompletableSource
to become the next source to be subscribed toconcatMapCompletable(Function, int)
@CheckReturnValue@SchedulerSupport(value="none")public final Completable concatMapCompletableDelayError(Function<? superT,? extendsCompletableSource> mapper, boolean tillTheEnd)
CompletableSource
s and subscribes to them one after the other terminates, optionally delaying all errors till both thisObservable
and all innerCompletableSource
s terminate.concatMapCompletableDelayError
does not operate by default on a particularScheduler
.History: 2.1.11 - experimental
mapper
- the function called with the upstream item and should return aCompletableSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from thisObservable
or any of the innerCompletableSource
s are delayed until all of them terminate. Iffalse
, an error from thisObservable
is delayed until the current innerCompletableSource
terminates and only then is it emitted to the downstream.concatMapCompletable(Function)
@CheckReturnValue@SchedulerSupport(value="none")public final Completable concatMapCompletableDelayError(Function<? superT,? extendsCompletableSource> mapper, boolean tillTheEnd, int prefetch)
CompletableSource
s and subscribes to them one after the other terminates, optionally delaying all errors till both thisObservable
and all innerCompletableSource
s terminate.concatMapCompletableDelayError
does not operate by default on a particularScheduler
.History: 2.1.11 - experimental
mapper
- the function called with the upstream item and should return aCompletableSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from thisObservable
or any of the innerCompletableSource
s are delayed until all of them terminate. Iffalse
, an error from thisObservable
is delayed until the current innerCompletableSource
terminates and only then is it emitted to the downstream.prefetch
- The number of upstream items to prefetch so that fresh items are ready to be mapped when a previousCompletableSource
terminates. The operator replenishes after half of the prefetch amount has been consumed and turned intoCompletableSource
s.concatMapCompletable(Function, int)
@CheckReturnValue@SchedulerSupport(value="none")public final <U> Observable<U> concatMapIterable(Function<? superT,? extendsIterable<? extends U>> mapper)
concatMapIterable
does not operate by default on a particularScheduler
.U
- the type of item emitted by the resulting ObservableSourcemapper
- a function that returns an Iterable sequence of values for when given an item emitted by the source ObservableSourcecollectionSelector
@CheckReturnValue@SchedulerSupport(value="none")public final <U> Observable<U> concatMapIterable(Function<? superT,? extendsIterable<? extends U>> mapper, int prefetch)
concatMapIterable
does not operate by default on a particularScheduler
.U
- the type of item emitted by the resulting ObservableSourcemapper
- a function that returns an Iterable sequence of values for when given an item emitted by the source ObservableSourceprefetch
- the number of elements to prefetch from the current ObservablecollectionSelector
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMapMaybe(Function<? superT,? extendsMaybeSource<? extends R>> mapper)
MaybeSource
s and subscribes to them one after the other succeeds or completes, emits their success value if available or terminates immediately if either thisObservable
or the current innerMaybeSource
fail.concatMapMaybe
does not operate by default on a particularScheduler
.History: 2.1.11 - experimental
R
- the result type of the innerMaybeSource
smapper
- the function called with the upstream item and should return aMaybeSource
to become the next source to be subscribed toconcatMapMaybeDelayError(Function)
,concatMapMaybe(Function, int)
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMapMaybe(Function<? superT,? extendsMaybeSource<? extends R>> mapper, int prefetch)
MaybeSource
s and subscribes to them one after the other succeeds or completes, emits their success value if available or terminates immediately if either thisObservable
or the current innerMaybeSource
fail.concatMapMaybe
does not operate by default on a particularScheduler
.History: 2.1.11 - experimental
R
- the result type of the innerMaybeSource
smapper
- the function called with the upstream item and should return aMaybeSource
to become the next source to be subscribed toprefetch
- The number of upstream items to prefetch so that fresh items are ready to be mapped when a previousMaybeSource
terminates. The operator replenishes after half of the prefetch amount has been consumed and turned intoMaybeSource
s.concatMapMaybe(Function)
,concatMapMaybeDelayError(Function, boolean, int)
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMapMaybeDelayError(Function<? superT,? extendsMaybeSource<? extends R>> mapper)
MaybeSource
s and subscribes to them one after the other terminates, emits their success value if available and delaying all errors till both thisObservable
and all innerMaybeSource
s terminate.concatMapMaybeDelayError
does not operate by default on a particularScheduler
.History: 2.1.11 - experimental
R
- the result type of the innerMaybeSource
smapper
- the function called with the upstream item and should return aMaybeSource
to become the next source to be subscribed toconcatMapMaybe(Function)
,concatMapMaybeDelayError(Function, boolean)
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMapMaybeDelayError(Function<? superT,? extendsMaybeSource<? extends R>> mapper, boolean tillTheEnd)
MaybeSource
s and subscribes to them one after the other terminates, emits their success value if available and optionally delaying all errors till both thisObservable
and all innerMaybeSource
s terminate.concatMapMaybeDelayError
does not operate by default on a particularScheduler
.History: 2.1.11 - experimental
R
- the result type of the innerMaybeSource
smapper
- the function called with the upstream item and should return aMaybeSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from thisObservable
or any of the innerMaybeSource
s are delayed until all of them terminate. Iffalse
, an error from thisObservable
is delayed until the current innerMaybeSource
terminates and only then is it emitted to the downstream.concatMapMaybe(Function, int)
,concatMapMaybeDelayError(Function, boolean, int)
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMapMaybeDelayError(Function<? superT,? extendsMaybeSource<? extends R>> mapper, boolean tillTheEnd, int prefetch)
MaybeSource
s and subscribes to them one after the other terminates, emits their success value if available and optionally delaying all errors till both thisObservable
and all innerMaybeSource
s terminate.concatMapMaybeDelayError
does not operate by default on a particularScheduler
.History: 2.1.11 - experimental
R
- the result type of the innerMaybeSource
smapper
- the function called with the upstream item and should return aMaybeSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from thisObservable
or any of the innerMaybeSource
s are delayed until all of them terminate. Iffalse
, an error from thisObservable
is delayed until the current innerMaybeSource
terminates and only then is it emitted to the downstream.prefetch
- The number of upstream items to prefetch so that fresh items are ready to be mapped when a previousMaybeSource
terminates. The operator replenishes after half of the prefetch amount has been consumed and turned intoMaybeSource
s.concatMapMaybe(Function, int)
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMapSingle(Function<? superT,? extendsSingleSource<? extends R>> mapper)
SingleSource
s and subscribes to them one after the other succeeds, emits their success values or terminates immediately if either thisObservable
or the current innerSingleSource
fail.concatMapSingle
does not operate by default on a particularScheduler
.History: 2.1.11 - experimental
R
- the result type of the innerSingleSource
smapper
- the function called with the upstream item and should return aSingleSource
to become the next source to be subscribed toconcatMapSingleDelayError(Function)
,concatMapSingle(Function, int)
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMapSingle(Function<? superT,? extendsSingleSource<? extends R>> mapper, int prefetch)
SingleSource
s and subscribes to them one after the other succeeds, emits their success values or terminates immediately if either thisObservable
or the current innerSingleSource
fail.concatMapSingle
does not operate by default on a particularScheduler
.History: 2.1.11 - experimental
R
- the result type of the innerSingleSource
smapper
- the function called with the upstream item and should return aSingleSource
to become the next source to be subscribed toprefetch
- The number of upstream items to prefetch so that fresh items are ready to be mapped when a previousSingleSource
terminates. The operator replenishes after half of the prefetch amount has been consumed and turned intoSingleSource
s.concatMapSingle(Function)
,concatMapSingleDelayError(Function, boolean, int)
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMapSingleDelayError(Function<? superT,? extendsSingleSource<? extends R>> mapper)
SingleSource
s and subscribes to them one after the other succeeds or fails, emits their success values and delays all errors till both thisObservable
and all innerSingleSource
s terminate.concatMapSingleDelayError
does not operate by default on a particularScheduler
.History: 2.1.11 - experimental
R
- the result type of the innerSingleSource
smapper
- the function called with the upstream item and should return aSingleSource
to become the next source to be subscribed toconcatMapSingle(Function)
,concatMapSingleDelayError(Function, boolean)
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMapSingleDelayError(Function<? superT,? extendsSingleSource<? extends R>> mapper, boolean tillTheEnd)
SingleSource
s and subscribes to them one after the other succeeds or fails, emits their success values and optionally delays all errors till both thisObservable
and all innerSingleSource
s terminate.concatMapSingleDelayError
does not operate by default on a particularScheduler
.History: 2.1.11 - experimental
R
- the result type of the innerSingleSource
smapper
- the function called with the upstream item and should return aSingleSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from thisObservable
or any of the innerSingleSource
s are delayed until all of them terminate. Iffalse
, an error from thisObservable
is delayed until the current innerSingleSource
terminates and only then is it emitted to the downstream.concatMapSingle(Function, int)
,concatMapSingleDelayError(Function, boolean, int)
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> concatMapSingleDelayError(Function<? superT,? extendsSingleSource<? extends R>> mapper, boolean tillTheEnd, int prefetch)
SingleSource
s and subscribes to them one after the other succeeds or fails, emits their success values and optionally delays errors till both thisObservable
and all innerSingleSource
s terminate.concatMapSingleDelayError
does not operate by default on a particularScheduler
.History: 2.1.11 - experimental
R
- the result type of the innerSingleSource
smapper
- the function called with the upstream item and should return aSingleSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from thisObservable
or any of the innerSingleSource
s are delayed until all of them terminate. Iffalse
, an error from thisObservable
is delayed until the current innerSingleSource
terminates and only then is it emitted to the downstream.prefetch
- The number of upstream items to prefetch so that fresh items are ready to be mapped when a previousSingleSource
terminates. The operator replenishes after half of the prefetch amount has been consumed and turned intoSingleSource
s.concatMapSingle(Function, int)
@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> concatWith(ObservableSource<? extendsT> other)
concatWith
does not operate by default on a particularScheduler
.other
- an ObservableSource to be concatenated after the current@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> concatWith(@NonNullSingleSource<? extendsT> other)
Observable
that emits the items from thisObservable
followed by the success item or error event of the otherSingleSource
.concatWith
does not operate by default on a particularScheduler
.History: 2.1.10 - experimental
other
- the SingleSource whose signal should be emitted after thisObservable
completes normally.@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> concatWith(@NonNullMaybeSource<? extendsT> other)
Observable
that emits the items from thisObservable
followed by the success item or terminal events of the otherMaybeSource
.concatWith
does not operate by default on a particularScheduler
.History: 2.1.10 - experimental
other
- the MaybeSource whose signal should be emitted after this Observable completes normally.@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> concatWith(@NonNullCompletableSource other)
Observable
that emits items from thisObservable
and when it completes normally, the otherCompletableSource
is subscribed to and the returnedObservable
emits its terminal events.concatWith
does not operate by default on a particularScheduler
.History: 2.1.10 - experimental
other
- theCompletableSource
to subscribe to once the currentObservable
completes normally@CheckReturnValue@SchedulerSupport(value="none")public final Single<Boolean> contains(Object element)
contains
does not operate by default on a particularScheduler
.element
- the item to search for in the emissions from the source ObservableSourcetrue
if the specified item is emitted by the source ObservableSource, orfalse
if the source ObservableSource completes without emitting that item@CheckReturnValue@SchedulerSupport(value="none")public final Single<Long> count()
count
does not operate by default on a particularScheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final <U> Observable<T> debounce(Function<? superT,? extendsObservableSource<U>> debounceSelector)
The delivery of the item happens on the thread of the firstonNext
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.Scheduler)
applied afterdebounce
itself.
debounce
does not operate by default on a particularScheduler
.U
- the debounce value type (ignored)debounceSelector
- function to retrieve a sequence that indicates the throttle duration for each item@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<T> debounce(long timeout,TimeUnit unit)
Note: If items keep being emitted by the source ObservableSource faster than the timeout then no items will be emitted by the resulting ObservableSource.
Delivery of the item after the grace period happens on thecomputation
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.Scheduler)
applied afterdebounce
itself.
debounce
operates by default on thecomputation
Scheduler
.timeout
- the length of the window of time that must pass after the emission of an item from the source ObservableSource in which that ObservableSource emits no items in order for the item to be emitted by the resulting ObservableSourceunit
- the unit of time for the specifiedtimeout
throttleWithTimeout(long, TimeUnit)
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> debounce(long timeout,TimeUnit unit,Scheduler scheduler)
Note: If items keep being emitted by the source ObservableSource faster than the timeout then no items will be emitted by the resulting ObservableSource.
Delivery of the item after the grace period happens on the givenScheduler
'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.Scheduler)
applied afterdebounce
itself.
Scheduler
this operator will use.timeout
- the time each item has to be "the most recent" of those emitted by the source ObservableSource 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 itemthrottleWithTimeout(long, TimeUnit, Scheduler)
@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> defaultIfEmpty(T defaultItem)
defaultIfEmpty
does not operate by default on a particularScheduler
.defaultItem
- the item to emit if the source ObservableSource emits no items@CheckReturnValue@SchedulerSupport(value="none")public final <U> Observable<T> delay(Function<? superT,? extendsObservableSource<U>> itemDelay)
Note: the resulting ObservableSource will immediately propagate anyonError
notification from the source ObservableSource.
delay
does not operate by default on a particularScheduler
.U
- the item delay value type (ignored)itemDelay
- a function that returns an ObservableSource for each item emitted by the source ObservableSource, which is then used to delay the emission of that item by the resulting ObservableSource until the ObservableSource returned fromitemDelay
emits an item@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<T> delay(long delay,TimeUnit unit)
delay
operates by default on thecomputation
Scheduler
.delay
- the delay to shift the source byunit
- theTimeUnit
in whichperiod
is defined@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<T> delay(long delay,TimeUnit unit, boolean delayError)
delayError
is true, error notifications will also be delayed.delay
operates by default on thecomputation
Scheduler
.delay
- the delay to shift the source byunit
- theTimeUnit
in whichperiod
is defineddelayError
- if true, the upstream exception is signalled with the given delay, after all preceding normal elements, if false, the upstream exception is signalled immediately@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> delay(long delay,TimeUnit unit,Scheduler scheduler)
Scheduler
this operator will use.delay
- the delay to shift the source byunit
- the time unit ofdelay
scheduler
- theScheduler
to use for delaying@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> delay(long delay,TimeUnit unit,Scheduler scheduler, boolean delayError)
delayError
is true, error notifications will also be delayed.Scheduler
this operator will use.delay
- the delay to shift the source byunit
- the time unit ofdelay
scheduler
- theScheduler
to use for delayingdelayError
- if true, the upstream exception is signalled with the given delay, after all preceding normal elements, if false, the upstream exception is signalled immediately@CheckReturnValue@SchedulerSupport(value="none")public final <U,V> Observable<T> delay(ObservableSource<U> subscriptionDelay,Function<? superT,? extendsObservableSource<V>> itemDelay)
Note: the resulting ObservableSource will immediately propagate anyonError
notification from the source ObservableSource.
delay
does not operate by default on a particularScheduler
.U
- the subscription delay value type (ignored)V
- the item delay value type (ignored)subscriptionDelay
- a function that returns an ObservableSource that triggers the subscription to the source ObservableSource once it emits any itemitemDelay
- a function that returns an ObservableSource for each item emitted by the source ObservableSource, which is then used to delay the emission of that item by the resulting ObservableSource until the ObservableSource returned fromitemDelay
emits an item@CheckReturnValue@SchedulerSupport(value="none")public final <U> Observable<T> delaySubscription(ObservableSource<U> other)
Scheduler
.U
- the value type of the other Observable, irrelevantother
- the other Observable that should trigger the subscription to this Observable.@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<T> delaySubscription(long delay,TimeUnit unit)
delaySubscription
operates by default on thecomputation
Scheduler
.delay
- the time to delay the subscriptionunit
- the time unit ofdelay
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> delaySubscription(long delay,TimeUnit unit,Scheduler scheduler)
Scheduler
this operator will use.delay
- the time to delay the subscriptionunit
- the time unit ofdelay
scheduler
- the Scheduler on which the waiting and subscription will happen@CheckReturnValue@SchedulerSupport(value="none")@Deprecatedpublic final <T2> Observable<T2> dematerialize()
dematerialize(Function)
instead.materialize
by transforming theNotification
objects emitted by the source ObservableSource into the items or notifications they represent. When the upstream signals anonError
oronComplete
item, the returned Observable disposes of the flow and terminates with that type of terminal event:
Observable.just(createOnNext(1), createOnComplete(), createOnNext(2)) .doOnDispose(() -> System.out.println("Disposed!")); .dematerialize() .test() .assertResult(1);
If the upstream signalsonError
oronComplete
directly, the flow is terminated with the same event. Observable.just(createOnNext(1), createOnNext(2)) .dematerialize() .test() .assertResult(1, 2);
If this behavior is not desired, the completion can be suppressed by applyingconcatWith(ObservableSource)
with anever()
source.dematerialize
does not operate by default on a particularScheduler
.T2
- the output value typeNotification
objects emitted by the source ObservableSourcedematerialize(Function)
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> dematerialize(Function<? superT,Notification<R>> selector)
materialize
by transforming theNotification
objects extracted from the source items via a selector function into their respectiveObserver
signal types. The intended use of theselector
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 anonError
oronComplete
item, the returned Observable disposes of the flow and terminates with that type of terminal event:
Observable.just(createOnNext(1), createOnComplete(), createOnNext(2)) .doOnDispose(() -> System.out.println("Disposed!")); .dematerialize(notification -> notification) .test() .assertResult(1);
If the upstream signalsonError
oronComplete
directly, the flow is terminated with the same event. Observable.just(createOnNext(1), createOnNext(2)) .dematerialize(notification -> notification) .test() .assertResult(1, 2);
If this behavior is not desired, the completion can be suppressed by applyingconcatWith(ObservableSource)
with anever()
source.dematerialize
does not operate by default on a particularScheduler
.R
- the output value typeselector
- function that returns the upstream item and should return a Notification to signal the correspondingObserver
event to the downstream.Notification
objects selected from the items emitted by the source ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> distinct()
Object.equals(Object)
comparison. It is recommended the elements' classT
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
per Observer to remember previously seen items and usesSet.add(Object)
returningfalse
as the indicator for duplicates.
Note that this internalHashSet
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 customCollection
implementation to thedistinct(Function, Callable)
overload.
distinct
does not operate by default on a particularScheduler
.distinct(Function)
,distinct(Function, Callable)
@CheckReturnValue@SchedulerSupport(value="none")public final <K> Observable<T> distinct(Function<? superT,K> keySelector)
Object.equals(Object)
comparison of the objects returned by the key selector function. It is recommended the keys' classK
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
per Observer to remember previously seen keys and usesSet.add(Object)
returningfalse
as the indicator for duplicates.
Note that this internalHashSet
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 customCollection
implementation to thedistinct(Function, Callable)
overload.
distinct
does not operate by default on a particularScheduler
.K
- the key typekeySelector
- 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 notdistinct(Function, Callable)
@CheckReturnValue@SchedulerSupport(value="none")public final <K> Observable<T> distinct(Function<? superT,K> keySelector,Callable<? extendsCollection<? super K>> collectionSupplier)
Object.equals(Object)
comparison of the objects returned by the key selector function. It is recommended the keys' classK
overrides the defaultObject.equals()
andObject.hashCode()
to provide meaningful comparison between the key objects as the default Java implementation only considers reference equivalence.
distinct
does not operate by default on a particularScheduler
.K
- the key typekeySelector
- 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 individual Observer to return a Collection subtype for holding the extracted keys and whose add() method's return indicates uniqueness.@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> distinctUntilChanged()
Object.equals(Object)
comparison. It is recommended the elements' classT
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 typeT
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)))
.
distinctUntilChanged
does not operate by default on a particularScheduler
.distinctUntilChanged(BiPredicate)
@CheckReturnValue@SchedulerSupport(value="none")public final <K> Observable<T> distinctUntilChanged(Function<? superT,K> keySelector)
Object.equals(Object)
comparison of those objects returned by the key selector function. It is recommended the keys' classK
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 typeT
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)))
.
distinctUntilChanged
does not operate by default on a particularScheduler
.K
- the key typekeySelector
- 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@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> distinctUntilChanged(BiPredicate<? superT,? superT> comparer)
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 typeT
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)))
.
distinctUntilChanged
does not operate by default on a particularScheduler
.comparer
- the function that receives the previous item and the current item and is expected to return true if the two are equal, thus skipping the current value.@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> doAfterNext(Consumer<? superT> onAfterNext)
Note that theonAfterNext
action is shared between subscriptions and as such should be thread-safe.
doAfterNext
does not operate by default on a particularScheduler
.History: 2.0.1 - experimental
onAfterNext
- the Consumer that will be called after emitting an item from upstream to the downstream@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> doAfterTerminate(Action onFinally)
Action
to be called when this ObservableSource invokes eitheronComplete
oronError
.doAfterTerminate
does not operate by default on a particularScheduler
.onFinally
- anAction
to be invoked when the source ObservableSource finishesAction
doOnTerminate(Action)
@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> doFinally(Action onFinally)
In case of a race between a terminal event and a dispose call, the providedonFinally
action is executed once per subscription.
Note that theonFinally
action is shared between subscriptions and as such should be thread-safe.
doFinally
does not operate by default on a particularScheduler
.History: 2.0.1 - experimental
onFinally
- the action called when this Observable terminates or gets disposed@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> doOnDispose(Action onDispose)
Action
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 thedispose()
call, sometimes as aCompositeException
if there were multiple exceptions along the way.
doOnDispose
does not operate by default on a particularScheduler
.onDispose
- the action that gets called when the sourceObservableSource
's Disposable is disposedObservableSource
modified so as to call this Action when appropriateNullPointerException
- if onDispose is null@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> doOnComplete(Action onComplete)
onComplete
.doOnComplete
does not operate by default on a particularScheduler
.onComplete
- the action to invoke when the source ObservableSource callsonComplete
@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> doOnEach(Consumer<? superNotification<T>> onNotification)
doOnEach
does not operate by default on a particularScheduler
.onNotification
- the action to invoke for each item emitted by the source ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> doOnEach(Observer<? superT> observer)
In case theonError
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.
doOnEach
does not operate by default on a particularScheduler
.observer
- the observer to be notified about onNext, onError and onComplete events on its respective methods before the actual downstream Observer gets notified.@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> doOnError(Consumer<? superThrowable> onError)
onError
. In case theonError
action throws, the downstream will receive a composite exception containing the original exception and the exception thrown byonError
.
doOnError
does not operate by default on a particularScheduler
.onError
- the action to invoke if the source ObservableSource callsonError
@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> doOnLifecycle(Consumer<? superDisposable> onSubscribe,Action onDispose)
doOnLifecycle
does not operate by default on a particularScheduler
.onSubscribe
- a Consumer called with the Disposable sent via Observer.onSubscribe()onDispose
- called when the downstream disposes the Disposable via dispose()@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> doOnNext(Consumer<? superT> onNext)
onNext
.doOnNext
does not operate by default on a particularScheduler
.onNext
- the action to invoke when the source ObservableSource callsonNext
@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> doOnSubscribe(Consumer<? superDisposable> onSubscribe)
ObservableSource
so that it invokes the given action when it is subscribed from its subscribers. Each subscription will result in an invocation of the given action except when the sourceObservableSource
is reference counted, in which case the sourceObservableSource
will invoke the given action for the first subscription.doOnSubscribe
does not operate by default on a particularScheduler
.onSubscribe
- the Consumer that gets called when an Observer subscribes to the currentObservable
ObservableSource
modified so as to call this Consumer when appropriate@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> doOnTerminate(Action onTerminate)
onComplete
oronError
. This differs fromdoAfterTerminate
in that this happensbefore theonComplete
oronError
notification.
doOnTerminate
does not operate by default on a particularScheduler
.onTerminate
- the action to invoke when the source ObservableSource callsonComplete
oronError
doAfterTerminate(Action)
@CheckReturnValue@SchedulerSupport(value="none")public final Maybe<T> elementAt(long index)
elementAt
does not operate by default on a particularScheduler
.index
- the zero-based index of the item to retrieveIndexOutOfBoundsException
- ifindex
is less than 0@CheckReturnValue@SchedulerSupport(value="none")public final Single<T> elementAt(long index,T defaultItem)
elementAt
does not operate by default on a particularScheduler
.index
- the zero-based index of the item to retrievedefaultItem
- the default itemIndexOutOfBoundsException
- ifindex
is less than 0@CheckReturnValue@SchedulerSupport(value="none")public final Single<T> elementAtOrError(long index)
NoSuchElementException
if this Observable signals fewer elements than index.elementAtOrError
does not operate by default on a particularScheduler
.index
- the zero-based index of the item to retrieveIndexOutOfBoundsException
- ifindex
is less than 0@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> filter(Predicate<? superT> predicate)
filter
does not operate by default on a particularScheduler
.predicate
- a function that evaluates each item emitted by the source ObservableSource, returningtrue
if it passes the filtertrue
@CheckReturnValue@SchedulerSupport(value="none")public final Maybe<T> firstElement()
firstElement
does not operate by default on a particularScheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final Single<T> first(T defaultItem)
first
does not operate by default on a particularScheduler
.defaultItem
- the default item to emit if the source ObservableSource doesn't emit anything@CheckReturnValue@SchedulerSupport(value="none")public final Single<T> firstOrError()
NoSuchElementException
if this Observable is empty.firstOrError
does not operate by default on a particularScheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> flatMap(Function<? superT,? extendsObservableSource<? extends R>> mapper)
flatMap
does not operate by default on a particularScheduler
.R
- the value type of the inner ObservableSources and the output typemapper
- a function that, when applied to an item emitted by the source ObservableSource, returns an ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> flatMap(Function<? superT,? extendsObservableSource<? extends R>> mapper, boolean delayErrors)
flatMap
does not operate by default on a particularScheduler
.R
- the value type of the inner ObservableSources and the output typemapper
- a function that, when applied to an item emitted by the source ObservableSource, returns an ObservableSourcedelayErrors
- if true, exceptions from the current Observable and all inner ObservableSources are delayed until all of them terminate if false, the first one signalling an exception will terminate the whole sequence immediately@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> flatMap(Function<? superT,? extendsObservableSource<? extends R>> mapper, boolean delayErrors, int maxConcurrency)
flatMap
does not operate by default on a particularScheduler
.R
- the value type of the inner ObservableSources and the output typemapper
- a function that, when applied to an item emitted by the source ObservableSource, returns an ObservableSourcemaxConcurrency
- the maximum number of ObservableSources that may be subscribed to concurrentlydelayErrors
- if true, exceptions from the current Observable and all inner ObservableSources are delayed until all of them terminate if false, the first one signalling an exception will terminate the whole sequence immediately@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> flatMap(Function<? superT,? extendsObservableSource<? extends R>> mapper, boolean delayErrors, int maxConcurrency, int bufferSize)
flatMap
does not operate by default on a particularScheduler
.R
- the value type of the inner ObservableSources and the output typemapper
- a function that, when applied to an item emitted by the source ObservableSource, returns an ObservableSourcemaxConcurrency
- the maximum number of ObservableSources that may be subscribed to concurrentlydelayErrors
- if true, exceptions from the current Observable and all inner ObservableSources are delayed until all of them terminate if false, the first one signalling an exception will terminate the whole sequence immediatelybufferSize
- the number of elements to prefetch from each inner ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> flatMap(Function<? superT,? extendsObservableSource<? extends R>> onNextMapper,Function<? superThrowable,? extendsObservableSource<? extends R>> onErrorMapper,Callable<? extendsObservableSource<? extends R>> onCompleteSupplier)
flatMap
does not operate by default on a particularScheduler
.R
- the result typeonNextMapper
- a function that returns an ObservableSource to merge for each item emitted by the source ObservableSourceonErrorMapper
- a function that returns an ObservableSource to merge for an onError notification from the source ObservableSourceonCompleteSupplier
- a function that returns an ObservableSource to merge for an onComplete notification from the source ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> flatMap(Function<? superT,? extendsObservableSource<? extends R>> onNextMapper,Function<Throwable,? extendsObservableSource<? extends R>> onErrorMapper,Callable<? extendsObservableSource<? extends R>> onCompleteSupplier, int maxConcurrency)
flatMap
does not operate by default on a particularScheduler
.R
- the result typeonNextMapper
- a function that returns an ObservableSource to merge for each item emitted by the source ObservableSourceonErrorMapper
- a function that returns an ObservableSource to merge for an onError notification from the source ObservableSourceonCompleteSupplier
- a function that returns an ObservableSource to merge for an onComplete notification from the source ObservableSourcemaxConcurrency
- the maximum number of ObservableSources that may be subscribed to concurrently@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> flatMap(Function<? superT,? extendsObservableSource<? extends R>> mapper, int maxConcurrency)
flatMap
does not operate by default on a particularScheduler
.R
- the value type of the inner ObservableSources and the output typemapper
- a function that, when applied to an item emitted by the source ObservableSource, returns an ObservableSourcemaxConcurrency
- the maximum number of ObservableSources that may be subscribed to concurrently@CheckReturnValue@SchedulerSupport(value="none")public final <U,R> Observable<R> flatMap(Function<? superT,? extendsObservableSource<? extends U>> mapper,BiFunction<? superT,? super U,? extends R> resultSelector)
flatMap
does not operate by default on a particularScheduler
.U
- the type of items emitted by the collection ObservableSourceR
- the type of items emitted by the resulting ObservableSourcemapper
- a function that returns an ObservableSource for each item emitted by the source ObservableSourceresultSelector
- a function that combines one item emitted by each of the source and collection ObservableSources and returns an item to be emitted by the resulting ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final <U,R> Observable<R> flatMap(Function<? superT,? extendsObservableSource<? extends U>> mapper,BiFunction<? superT,? super U,? extends R> combiner, boolean delayErrors)
flatMap
does not operate by default on a particularScheduler
.U
- the type of items emitted by the collection ObservableSourceR
- the type of items emitted by the resulting ObservableSourcemapper
- a function that returns an ObservableSource for each item emitted by the source ObservableSourcecombiner
- a function that combines one item emitted by each of the source and collection ObservableSources and returns an item to be emitted by the resulting ObservableSourcedelayErrors
- if true, exceptions from the current Observable and all inner ObservableSources are delayed until all of them terminate if false, the first one signalling an exception will terminate the whole sequence immediately@CheckReturnValue@SchedulerSupport(value="none")public final <U,R> Observable<R> flatMap(Function<? superT,? extendsObservableSource<? extends U>> mapper,BiFunction<? superT,? super U,? extends R> combiner, boolean delayErrors, int maxConcurrency)
flatMap
does not operate by default on a particularScheduler
.U
- the type of items emitted by the collection ObservableSourceR
- the type of items emitted by the resulting ObservableSourcemapper
- a function that returns an ObservableSource for each item emitted by the source ObservableSourcecombiner
- a function that combines one item emitted by each of the source and collection ObservableSources and returns an item to be emitted by the resulting ObservableSourcemaxConcurrency
- the maximum number of ObservableSources that may be subscribed to concurrentlydelayErrors
- if true, exceptions from the current Observable and all inner ObservableSources are delayed until all of them terminate if false, the first one signalling an exception will terminate the whole sequence immediately@CheckReturnValue@SchedulerSupport(value="none")public final <U,R> Observable<R> flatMap(Function<? superT,? extendsObservableSource<? extends U>> mapper,BiFunction<? superT,? super U,? extends R> combiner, boolean delayErrors, int maxConcurrency, int bufferSize)
flatMap
does not operate by default on a particularScheduler
.U
- the type of items emitted by the collection ObservableSourceR
- the type of items emitted by the resulting ObservableSourcemapper
- a function that returns an ObservableSource for each item emitted by the source ObservableSourcecombiner
- a function that combines one item emitted by each of the source and collection ObservableSources and returns an item to be emitted by the resulting ObservableSourcemaxConcurrency
- the maximum number of ObservableSources that may be subscribed to concurrentlydelayErrors
- if true, exceptions from the current Observable and all inner ObservableSources are delayed until all of them terminate if false, the first one signalling an exception will terminate the whole sequence immediatelybufferSize
- the number of elements to prefetch from the inner ObservableSources.@CheckReturnValue@SchedulerSupport(value="none")public final <U,R> Observable<R> flatMap(Function<? superT,? extendsObservableSource<? extends U>> mapper,BiFunction<? superT,? super U,? extends R> combiner, int maxConcurrency)
flatMap
does not operate by default on a particularScheduler
.U
- the type of items emitted by the collection ObservableSourceR
- the type of items emitted by the resulting ObservableSourcemapper
- a function that returns an ObservableSource for each item emitted by the source ObservableSourcecombiner
- a function that combines one item emitted by each of the source and collection ObservableSources and returns an item to be emitted by the resulting ObservableSourcemaxConcurrency
- the maximum number of ObservableSources that may be subscribed to concurrently@CheckReturnValue@SchedulerSupport(value="none")public final Completable flatMapCompletable(Function<? superT,? extendsCompletableSource> mapper)
flatMapCompletable
does not operate by default on a particularScheduler
.mapper
- the function that received each source value and transforms them into CompletableSources.@CheckReturnValue@SchedulerSupport(value="none")public final Completable flatMapCompletable(Function<? superT,? extendsCompletableSource> mapper, boolean delayErrors)
flatMapCompletable
does not operate by default on a particularScheduler
.mapper
- the function that received each source value and transforms them into CompletableSources.delayErrors
- if true errors from the upstream and inner CompletableSources are delayed until each of them terminates.@CheckReturnValue@SchedulerSupport(value="none")public final <U> Observable<U> flatMapIterable(Function<? superT,? extendsIterable<? extends U>> mapper)
flatMapIterable
does not operate by default on a particularScheduler
.U
- the type of item emitted by the resulting Iterablemapper
- a function that returns an Iterable sequence of values for when given an item emitted by the source ObservableSourcecollectionSelector
@CheckReturnValue@SchedulerSupport(value="none")public final <U,V> Observable<V> flatMapIterable(Function<? superT,? extendsIterable<? extends U>> mapper,BiFunction<? superT,? super U,? extends V> resultSelector)
flatMapIterable
does not operate by default on a particularScheduler
.U
- the collection element typeV
- the type of item emitted by the resulting Iterablemapper
- a function that returns an Iterable sequence of values for each item emitted by the source ObservableSourceresultSelector
- a function that returns an item based on the item emitted by the source ObservableSource and the Iterable returned for that item by thecollectionSelector
resultSelector
for each item in the source ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> flatMapMaybe(Function<? superT,? extendsMaybeSource<? extends R>> mapper)
flatMapMaybe
does not operate by default on a particularScheduler
.R
- the result value typemapper
- the function that received each source value and transforms them into MaybeSources.@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> flatMapMaybe(Function<? superT,? extendsMaybeSource<? extends R>> mapper, boolean delayErrors)
flatMapMaybe
does not operate by default on a particularScheduler
.R
- the result value typemapper
- the function that received each source value and transforms them into MaybeSources.delayErrors
- if true errors from the upstream and inner MaybeSources are delayed until each of them terminates.@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> flatMapSingle(Function<? superT,? extendsSingleSource<? extends R>> mapper)
flatMapSingle
does not operate by default on a particularScheduler
.R
- the result value typemapper
- the function that received each source value and transforms them into SingleSources.@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> flatMapSingle(Function<? superT,? extendsSingleSource<? extends R>> mapper, boolean delayErrors)
flatMapSingle
does not operate by default on a particularScheduler
.R
- the result value typemapper
- the function that received each source value and transforms them into SingleSources.delayErrors
- if true errors from the upstream and inner SingleSources are delayed until each of them terminates.@CheckReturnValue@SchedulerSupport(value="none")public final Disposable forEach(Consumer<? superT> onNext)
ObservableSource
and receives notifications for each element. Alias tosubscribe(Consumer)
forEach
does not operate by default on a particularScheduler
.onNext
-Consumer
to execute for each item.NullPointerException
- ifonNext
is null@CheckReturnValue@SchedulerSupport(value="none")public final Disposable forEachWhile(Predicate<? superT> onNext)
ObservableSource
and receives notifications for each element until the onNext Predicate returns false. If the Observable emits an error, it is wrapped into anOnErrorNotImplementedException
and routed to the RxJavaPlugins.onError handler.
forEachWhile
does not operate by default on a particularScheduler
.onNext
-Predicate
to execute for each item.NullPointerException
- ifonNext
is null@CheckReturnValue@SchedulerSupport(value="none")public final Disposable forEachWhile(Predicate<? superT> onNext,Consumer<? superThrowable> onError)
ObservableSource
and receives notifications for each element and error events until the onNext Predicate returns false.forEachWhile
does not operate by default on a particularScheduler
.onNext
-Predicate
to execute for each item.onError
-Consumer
to execute when an error is emitted.NullPointerException
- ifonNext
is null, or ifonError
is null@CheckReturnValue@SchedulerSupport(value="none")public final Disposable forEachWhile(Predicate<? superT> onNext,Consumer<? superThrowable> onError,Action onComplete)
ObservableSource
and receives notifications for each element and the terminal events until the onNext Predicate returns false.forEachWhile
does not operate by default on a particularScheduler
.onNext
-Predicate
to execute for each item.onError
-Consumer
to execute when an error is emitted.onComplete
-Action
to execute when completion is signalled.NullPointerException
- ifonNext
is null, or ifonError
is null, or ifonComplete
is null@CheckReturnValue@SchedulerSupport(value="none")public final <K> Observable<GroupedObservable<K,T>> groupBy(Function<? superT,? extends K> keySelector)
ObservableSource
according to a specified criterion, and emits these grouped items asGroupedObservable
s. The emittedGroupedObservableSource
allows only a singleObserver
during its lifetime and if thisObserver
calls dispose() before the source terminates, the next emission by the source having the same key will trigger a newGroupedObservableSource
emission.Note: AGroupedObservable
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 thoseGroupedObservableSource
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.
groupBy
does not operate by default on a particularScheduler
.K
- the key typekeySelector
- a function that extracts the key for each itemObservableSource
that emitsGroupedObservable
s, each of which corresponds to a unique key value and each of which emits those items from the source ObservableSource that share that key value@CheckReturnValue@SchedulerSupport(value="none")public final <K> Observable<GroupedObservable<K,T>> groupBy(Function<? superT,? extends K> keySelector, boolean delayError)
ObservableSource
according to a specified criterion, and emits these grouped items asGroupedObservable
s. The emittedGroupedObservableSource
allows only a singleObserver
during its lifetime and if thisObserver
calls dispose() before the source terminates, the next emission by the source having the same key will trigger a newGroupedObservableSource
emission.Note: AGroupedObservable
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 thoseGroupedObservableSource
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.
groupBy
does not operate by default on a particularScheduler
.K
- the key typekeySelector
- a function that extracts the key for each itemdelayError
- if true, the exception from the current Observable is delayed in each group until that specific group emitted the normal values; if false, the exception bypasses values in the groups and is reported immediately.ObservableSource
that emitsGroupedObservable
s, each of which corresponds to a unique key value and each of which emits those items from the source ObservableSource that share that key value@CheckReturnValue@SchedulerSupport(value="none")public final <K,V> Observable<GroupedObservable<K,V>> groupBy(Function<? superT,? extends K> keySelector,Function<? superT,? extends V> valueSelector)
ObservableSource
according to a specified criterion, and emits these grouped items asGroupedObservable
s. The emittedGroupedObservableSource
allows only a singleObserver
during its lifetime and if thisObserver
calls dispose() before the source terminates, the next emission by the source having the same key will trigger a newGroupedObservableSource
emission.Note: AGroupedObservable
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 thoseGroupedObservableSource
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.
groupBy
does not operate by default on a particularScheduler
.K
- the key typeV
- the element typekeySelector
- a function that extracts the key for each itemvalueSelector
- a function that extracts the return element for each itemObservableSource
that emitsGroupedObservable
s, each of which corresponds to a unique key value and each of which emits those items from the source ObservableSource that share that key value@CheckReturnValue@SchedulerSupport(value="none")public final <K,V> Observable<GroupedObservable<K,V>> groupBy(Function<? superT,? extends K> keySelector,Function<? superT,? extends V> valueSelector, boolean delayError)
ObservableSource
according to a specified criterion, and emits these grouped items asGroupedObservable
s. The emittedGroupedObservableSource
allows only a singleObserver
during its lifetime and if thisObserver
calls dispose() before the source terminates, the next emission by the source having the same key will trigger a newGroupedObservableSource
emission.Note: AGroupedObservable
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 thoseGroupedObservableSource
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.
groupBy
does not operate by default on a particularScheduler
.K
- the key typeV
- the element typekeySelector
- a function that extracts the key for each itemvalueSelector
- a function that extracts the return element for each itemdelayError
- if true, the exception from the current Observable is delayed in each group until that specific group emitted the normal values; if false, the exception bypasses values in the groups and is reported immediately.ObservableSource
that emitsGroupedObservable
s, each of which corresponds to a unique key value and each of which emits those items from the source ObservableSource that share that key value@CheckReturnValue@SchedulerSupport(value="none")public final <K,V> Observable<GroupedObservable<K,V>> groupBy(Function<? superT,? extends K> keySelector,Function<? superT,? extends V> valueSelector, boolean delayError, int bufferSize)
ObservableSource
according to a specified criterion, and emits these grouped items asGroupedObservable
s. The emittedGroupedObservableSource
allows only a singleObserver
during its lifetime and if thisObserver
calls dispose() before the source terminates, the next emission by the source having the same key will trigger a newGroupedObservableSource
emission.Note: AGroupedObservable
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 thoseGroupedObservableSource
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.
groupBy
does not operate by default on a particularScheduler
.K
- the key typeV
- the element typekeySelector
- a function that extracts the key for each itemvalueSelector
- a function that extracts the return element for each itemdelayError
- if true, the exception from the current Observable is delayed in each group until that specific group emitted the normal values; if false, the exception bypasses values in the groups and is reported immediately.bufferSize
- the hint for how manyGroupedObservable
s and element in eachGroupedObservable
should be bufferedObservableSource
that emitsGroupedObservable
s, each of which corresponds to a unique key value and each of which emits those items from the source ObservableSource that share that key value@CheckReturnValue@SchedulerSupport(value="none")public final <TRight,TLeftEnd,TRightEnd,R> Observable<R> groupJoin(ObservableSource<? extends TRight> other,Function<? superT,? extendsObservableSource<TLeftEnd>> leftEnd,Function<? super TRight,? extendsObservableSource<TRightEnd>> rightEnd,BiFunction<? superT,? superObservable<TRight>,? extends R> resultSelector)
There are no guarantees in what order the items get combined when multiple items from one or both source ObservableSources overlap.
groupJoin
does not operate by default on a particularScheduler
.TRight
- the value type of the right ObservableSource sourceTLeftEnd
- the element type of the left duration ObservableSourcesTRightEnd
- the element type of the right duration ObservableSourcesR
- the result typeother
- the other ObservableSource to correlate items from the source ObservableSource withleftEnd
- a function that returns an ObservableSource whose emissions indicate the duration of the values of the source ObservableSourcerightEnd
- a function that returns an ObservableSource whose emissions indicate the duration of the values of theright
ObservableSourceresultSelector
- a function that takes an item emitted by each ObservableSource and returns the value to be emitted by the resulting ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> hide()
Allows hiding extra features such asSubject
'sObserver
methods or preventing certain identity-based optimizations (fusion).
hide
does not operate by default on a particularScheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final Completable ignoreElements()
onComplete
oronError
.ignoreElements
does not operate by default on a particularScheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final Single<Boolean> isEmpty()
true
if the source ObservableSource is empty, otherwisefalse
. In Rx.Net this is negated as theany
Observer but we renamed this in RxJava to better match Java naming idioms.
isEmpty
does not operate by default on a particularScheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final <TRight,TLeftEnd,TRightEnd,R> Observable<R> join(ObservableSource<? extends TRight> other,Function<? superT,? extendsObservableSource<TLeftEnd>> leftEnd,Function<? super TRight,? extendsObservableSource<TRightEnd>> rightEnd,BiFunction<? superT,? super TRight,? extends R> resultSelector)
There are no guarantees in what order the items get combined when multiple items from one or both source ObservableSources overlap.
join
does not operate by default on a particularScheduler
.TRight
- the value type of the right ObservableSource sourceTLeftEnd
- the element type of the left duration ObservableSourcesTRightEnd
- the element type of the right duration ObservableSourcesR
- the result typeother
- the second ObservableSource to join items fromleftEnd
- a function to select a duration for each item emitted by the source ObservableSource, 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 resulting ObservableSource for any two overlapping items emitted by the two ObservableSources@CheckReturnValue@SchedulerSupport(value="none")public final Maybe<T> lastElement()
lastElement
does not operate by default on a particularScheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final Single<T> last(T defaultItem)
last
does not operate by default on a particularScheduler
.defaultItem
- the default item to emit if the source ObservableSource is empty@CheckReturnValue@SchedulerSupport(value="none")public final Single<T> lastOrError()
NoSuchElementException
if this Observable is empty.lastOrError
does not operate by default on a particularScheduler
.NoSuchElementException
will be thrown.@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> lift(ObservableOperator<? extends R,? superT> lifter)
Observable
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 newObserver
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 theRxJava wiki: Writing operators page about the tools, requirements, rules, considerations and pitfalls of implementing them.
Note that implementing custom operators via thislift()
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 inlift()
as theapply()
method requires a non-nullObserver
instance to be returned, which is then unconditionally subscribed to the upstreamObservable
. 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.Observer<? super T>)
can decide to not subscribe to its upstream after all.
lift
does not operate by default on a particularScheduler
, however, theObservableOperator
may use aScheduler
to support its own asynchronous behavior.R
- the output value typelifter
- theObservableOperator
that receives the downstream'sObserver
and should return anObserver
with custom behavior to be used as the consumer for the currentObservable
.compose(ObservableTransformer)
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> map(Function<? superT,? extends R> mapper)
map
does not operate by default on a particularScheduler
.R
- the output typemapper
- a function to apply to each item emitted by the ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final Observable<Notification<T>> materialize()
Notification
objects.materialize
does not operate by default on a particularScheduler
.dematerialize(Function)
@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> mergeWith(ObservableSource<? extendsT> other)
You can combine items emitted by multiple ObservableSources so that they appear as a single ObservableSource, by using themergeWith
method.
mergeWith
does not operate by default on a particularScheduler
.other
- an ObservableSource to be merged@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> mergeWith(@NonNullSingleSource<? extendsT> other)
The success value of the otherSingleSource
can get interleaved at any point of thisObservable
sequence.
mergeWith
does not operate by default on a particularScheduler
.History: 2.1.10 - experimental
other
- theSingleSource
whose success value to merge with@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> mergeWith(@NonNullMaybeSource<? extendsT> other)
The success value of the otherMaybeSource
can get interleaved at any point of thisObservable
sequence.
mergeWith
does not operate by default on a particularScheduler
.History: 2.1.10 - experimental
other
- theMaybeSource
which provides a success value to merge with or completes@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> mergeWith(@NonNullCompletableSource other)
mergeWith
does not operate by default on a particularScheduler
.History: 2.1.10 - experimental
other
- theCompletableSource
to await for completion@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> observeOn(Scheduler scheduler)
Scheduler
, asynchronously with an unbounded buffer withFlowable.bufferSize()
"island size".Note that onError notifications will cut ahead of onNext notifications on the emission thread if Scheduler 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
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.
scheduler
- theScheduler
to notifyObserver
s onObserver
s are notified on the specifiedScheduler
subscribeOn(io.reactivex.Scheduler)
,observeOn(Scheduler, boolean)
,observeOn(Scheduler, boolean, int)
,delay(long, TimeUnit, Scheduler)
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> observeOn(Scheduler scheduler, boolean delayError)
Scheduler
, asynchronously with an unbounded buffer withFlowable.bufferSize()
"island size" and optionally delays onError 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
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.
scheduler
- theScheduler
to notifyObserver
s ondelayError
- indicates if the onError notification may not cut ahead of onNext notification on the other side of the scheduling boundary. If true a sequence ending in onError will be replayed in the same order as was received from upstreamObserver
s are notified on the specifiedScheduler
subscribeOn(io.reactivex.Scheduler)
,observeOn(Scheduler)
,observeOn(Scheduler, boolean, int)
,delay(long, TimeUnit, Scheduler, boolean)
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> observeOn(Scheduler scheduler, boolean delayError, int bufferSize)
Scheduler
, asynchronously with an unbounded buffer of configurable "island size" and optionally delays onError 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
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.
scheduler
- theScheduler
to notifyObserver
s ondelayError
- indicates if the onError notification may not cut ahead of onNext notification on the other side of the scheduling boundary. If true a sequence ending in onError will be replayed in the same order as was received from upstreambufferSize
- the size of the buffer.Observer
s are notified on the specifiedScheduler
subscribeOn(io.reactivex.Scheduler)
,observeOn(Scheduler)
,observeOn(Scheduler, boolean)
,delay(long, TimeUnit, Scheduler, boolean)
@CheckReturnValue@SchedulerSupport(value="none")public final <U> Observable<U> ofType(Class<U> clazz)
ofType
does not operate by default on a particularScheduler
.U
- the output typeclazz
- the class type to filter the items emitted by the source ObservableSourceclazz
@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> onErrorResumeNext(Function<? superThrowable,? extendsObservableSource<? extendsT>> resumeFunction)
onError
if it encounters an error. By default, when an ObservableSource encounters an error that prevents it from emitting the expected item to itsObserver
, the ObservableSource invokes its Observer'sonError
method, and then quits without invoking any more of its Observer's methods. TheonErrorResumeNext
method changes this behavior. If you pass a function that returns an ObservableSource (resumeFunction
) toonErrorResumeNext
, if the original ObservableSource encounters an error, instead of invoking its Observer'sonError
method, it will instead relinquish control to the ObservableSource returned fromresumeFunction
, which will invoke the Observer'sonNext
method if it is able to do so. In such a case, because no ObservableSource necessarily invokesonError
, the Observer 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.
onErrorResumeNext
does not operate by default on a particularScheduler
.resumeFunction
- a function that returns an ObservableSource that will take over if the source ObservableSource encounters an error@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> onErrorResumeNext(ObservableSource<? extendsT> next)
onError
if it encounters an error. By default, when an ObservableSource encounters an error that prevents it from emitting the expected item to itsObserver
, the ObservableSource invokes its Observer'sonError
method, and then quits without invoking any more of its Observer's methods. TheonErrorResumeNext
method changes this behavior. If you pass another ObservableSource (resumeSequence
) to an ObservableSource'sonErrorResumeNext
method, if the original ObservableSource encounters an error, instead of invoking its Observer'sonError
method, it will instead relinquish control toresumeSequence
which will invoke the Observer'sonNext
method if it is able to do so. In such a case, because no ObservableSource necessarily invokesonError
, the Observer 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.
onErrorResumeNext
does not operate by default on a particularScheduler
.next
- the next ObservableSource source that will take over if the source ObservableSource encounters an error@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> onErrorReturn(Function<? superThrowable,? extendsT> valueSupplier)
onError
if it encounters an error. By default, when an ObservableSource encounters an error that prevents it from emitting the expected item to itsObserver
, the ObservableSource invokes its Observer'sonError
method, and then quits without invoking any more of its Observer's methods. TheonErrorReturn
method changes this behavior. If you pass a function (resumeFunction
) to an ObservableSource'sonErrorReturn
method, if the original ObservableSource encounters an error, instead of invoking its Observer'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.
onErrorReturn
does not operate by default on a particularScheduler
.valueSupplier
- a function that returns a single value that will be emitted along with a regular onComplete in case the current Observable signals an onError event@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> onErrorReturnItem(T item)
onError
if it encounters an error. By default, when an ObservableSource encounters an error that prevents it from emitting the expected item to itsObserver
, the ObservableSource invokes its Observer'sonError
method, and then quits without invoking any more of its Observer's methods. TheonErrorReturn
method changes this behavior. If you pass a function (resumeFunction
) to an ObservableSource'sonErrorReturn
method, if the original ObservableSource encounters an error, instead of invoking its Observer'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.
onErrorReturnItem
does not operate by default on a particularScheduler
.item
- the value that is emitted along with a regular onComplete in case the current Observable signals an exception@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> onExceptionResumeNext(ObservableSource<? extendsT> next)
onError
if it encounters anException
. This differs fromonErrorResumeNext(io.reactivex.functions.Function<? super java.lang.Throwable, ? extends io.reactivex.ObservableSource<? extends T>>)
in that this one does not handleThrowable
orError
but lets those continue through.
By default, when an ObservableSource encounters an exception that prevents it from emitting the expected item to itsObserver
, the ObservableSource invokes its Observer'sonError
method, and then quits without invoking any more of its Observer's methods. TheonExceptionResumeNext
method changes this behavior. If you pass another ObservableSource (resumeSequence
) to an ObservableSource'sonExceptionResumeNext
method, if the original ObservableSource encounters an exception, instead of invoking its Observer'sonError
method, it will instead relinquish control toresumeSequence
which will invoke the Observer'sonNext
method if it is able to do so. In such a case, because no ObservableSource necessarily invokesonError
, the Observer may never know that an exception happened.
You can use this to prevent exceptions from propagating or to supply fallback data should exceptions be encountered.
onExceptionResumeNext
does not operate by default on a particularScheduler
.next
- the next ObservableSource that will take over if the source ObservableSource encounters an exception@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> onTerminateDetach()
onTerminateDetach
does not operate by default on a particularScheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final ConnectableObservable<T> publish()
ConnectableObservable
, which is a variety of ObservableSource that waits until itsconnect
method is called before it begins emitting items to thoseObserver
s that have subscribed to it.publish
does not operate by default on a particularScheduler
.ConnectableObservable
that upon connection causes the source ObservableSource to emit items to itsObserver
s@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> publish(Function<? superObservable<T>,? extendsObservableSource<R>> selector)
ConnectableObservable
that shares a single subscription to the underlying sequence.publish
does not operate by default on a particularScheduler
.R
- the type of items emitted by the resulting ObservableSourceselector
- a function that can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Observers to the given source will receive all notifications of the source from the time of the subscription forward.ConnectableObservable
that shares a single subscription to the underlying sequence@CheckReturnValue@SchedulerSupport(value="none")public final Maybe<T> reduce(BiFunction<T,T,T> reducer)
This technique, which is called "reduce" here, is sometimes called "aggregate," "fold," "accumulate," "compress," or "inject" in other programming contexts. Groovy, for instance, has aninject
method that does a similar operation on lists.
Note that this operator requires the upstream to signalonComplete
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
.
reduce
does not operate by default on a particularScheduler
.reducer
- an accumulator function to be invoked on each item emitted by the source ObservableSource, whose result will be used in the next accumulator call@CheckReturnValue@SchedulerSupport(value="none")public final <R> Single<R> reduce(R seed,BiFunction<R,? superT,R> reducer)
This technique, which is called "reduce" here, is sometimes called "aggregate," "fold," "accumulate," "compress," or "inject" in other programming contexts. Groovy, for instance, has aninject
method that does a similar operation on lists.
Note that theseed
is shared among all subscribers to the resulting ObservableSource and may cause problems if it is mutable. To make sure each subscriber gets its own value, defer the application of this operator viadefer(Callable)
:
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 signalonComplete
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
.
reduce
does not operate by default on a particularScheduler
.R
- the accumulator and output value typeseed
- the initial (seed) accumulator valuereducer
- an accumulator function to be invoked on each item emitted by the source ObservableSource, the result of which will be used in the next accumulator callreduceWith(Callable, BiFunction)
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Single<R> reduceWith(Callable<R> seedSupplier,BiFunction<R,? superT,R> reducer)
This technique, which is called "reduce" here, is sometimes called "aggregate," "fold," "accumulate," "compress," or "inject" in other programming contexts. Groovy, for instance, has aninject
method that does a similar operation on lists.
Note that this operator requires the upstream to signalonComplete
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
.
reduceWith
does not operate by default on a particularScheduler
.R
- the accumulator and output value typeseedSupplier
- the Callable that provides the initial (seed) accumulator value for each individual Observerreducer
- an accumulator function to be invoked on each item emitted by the source ObservableSource, the result of which will be used in the next accumulator call@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> repeat()
repeat
does not operate by default on a particularScheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> repeat(long times)
count
times.repeat
does not operate by default on a particularScheduler
.times
- the number of times the source ObservableSource items are repeated, a count of 0 will yield an empty sequencecount
timesIllegalArgumentException
- ifcount
is less than zero@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> repeatUntil(BooleanSupplier stop)
repeatUntil
does not operate by default on a particularScheduler
.stop
- a boolean supplier that is called when the current Observable completes; if it returns true, the returned Observable completes; if it returns false, the upstream Observable is resubscribed.NullPointerException
- ifstop
is null@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> repeatWhen(Function<? superObservable<Object>,? extendsObservableSource<?>> handler)
onComplete
. AnonComplete
notification from the source will result in the emission of avoid
item to the ObservableSource provided as an argument to thenotificationHandler
function. If that ObservableSource callsonComplete
oronError
thenrepeatWhen
will callonComplete
oronError
on the child subscription. Otherwise, this ObservableSource will resubscribe to the source ObservableSource.repeatWhen
does not operate by default on a particularScheduler
.handler
- receives an ObservableSource of notifications with which a user can complete or error, aborting the repeat.@CheckReturnValue@SchedulerSupport(value="none")public final ConnectableObservable<T> replay()
ConnectableObservable
that shares a single subscription to the underlying ObservableSource that will replay all of its items and notifications to any futureObserver
. A Connectable ObservableSource resembles an ordinary ObservableSource, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.replay
does not operate by default on a particularScheduler
.ConnectableObservable
that upon connection causes the source ObservableSource to emit its items to itsObserver
s@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> replay(Function<? superObservable<T>,? extendsObservableSource<R>> selector)
ConnectableObservable
that shares a single subscription to the source ObservableSource.replay
does not operate by default on a particularScheduler
.R
- the type of items emitted by the resulting ObservableSourceselector
- the selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the ObservableSourceConnectableObservable
that shares a single subscription to the source ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> replay(Function<? superObservable<T>,? extendsObservableSource<R>> selector, int bufferSize)
ConnectableObservable
that shares a single subscription to the source ObservableSource, replayingbufferSize
notifications. Note that due to concurrency requirements,replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions.
replay
does not operate by default on a particularScheduler
.R
- the type of items emitted by the resulting ObservableSourceselector
- the selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the ObservableSourcebufferSize
- the buffer size that limits the number of items the connectable ObservableSource can replayConnectableObservable
that shares a single subscription to the source ObservableSource replaying no more thanbufferSize
items@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final <R> Observable<R> replay(Function<? superObservable<T>,? extendsObservableSource<R>> selector, int bufferSize, long time,TimeUnit unit)
ConnectableObservable
that shares a single subscription to the source ObservableSource, 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.
replay
operates by default on thecomputation
Scheduler
.R
- the type of items emitted by the resulting ObservableSourceselector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the ObservableSourcebufferSize
- the buffer size that limits the number of items the connectable ObservableSource can replaytime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
ConnectableObservable
that shares a single subscription to the source ObservableSource, and replays no more thanbufferSize
items that were emitted within the window defined bytime
@CheckReturnValue@SchedulerSupport(value="custom")public final <R> Observable<R> replay(Function<? superObservable<T>,? extendsObservableSource<R>> selector, int bufferSize, long time,TimeUnit unit,Scheduler scheduler)
ConnectableObservable
that shares a single subscription to the source ObservableSource, 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 operator will use.R
- the type of items emitted by the resulting ObservableSourceselector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the ObservableSourcebufferSize
- the buffer size that limits the number of items the connectable ObservableSource can replaytime
- 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 windowConnectableObservable
that shares a single subscription to the source ObservableSource, and replays no more thanbufferSize
items that were emitted within the window defined bytime
IllegalArgumentException
- ifbufferSize
is less than zero@CheckReturnValue@SchedulerSupport(value="custom")public final <R> Observable<R> replay(Function<? superObservable<T>,? extendsObservableSource<R>> selector, int bufferSize,Scheduler scheduler)
ConnectableObservable
that shares a single subscription to the source ObservableSource, replaying a maximum ofbufferSize
items. Note that due to concurrency requirements,replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions.
Scheduler
this operator will use.R
- the type of items emitted by the resulting ObservableSourceselector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the ObservableSourcebufferSize
- the buffer size that limits the number of items the connectable ObservableSource can replayscheduler
- the Scheduler on which the replay is observedConnectableObservable
that shares a single subscription to the source ObservableSource, replaying no more thanbufferSize
notifications@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final <R> Observable<R> replay(Function<? superObservable<T>,? extendsObservableSource<R>> selector, long time,TimeUnit unit)
ConnectableObservable
that shares a single subscription to the source ObservableSource, replaying all items that were emitted within a specified time window.replay
operates by default on thecomputation
Scheduler
.R
- the type of items emitted by the resulting ObservableSourceselector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the ObservableSourcetime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
ConnectableObservable
that shares a single subscription to the source ObservableSource, replaying all items that were emitted within the window defined bytime
@CheckReturnValue@SchedulerSupport(value="custom")public final <R> Observable<R> replay(Function<? superObservable<T>,? extendsObservableSource<R>> selector, long time,TimeUnit unit,Scheduler scheduler)
ConnectableObservable
that shares a single subscription to the source ObservableSource, replaying all items that were emitted within a specified time window.Scheduler
this operator will use.R
- the type of items emitted by the resulting ObservableSourceselector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the ObservableSourcetime
- 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 windowConnectableObservable
that shares a single subscription to the source ObservableSource, replaying all items that were emitted within the window defined bytime
@CheckReturnValue@SchedulerSupport(value="custom")public final <R> Observable<R> replay(Function<? superObservable<T>,? extendsObservableSource<R>> selector,Scheduler scheduler)
ConnectableObservable
that shares a single subscription to the source ObservableSource.Scheduler
this operator will use.R
- the type of items emitted by the resulting ObservableSourceselector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the ObservableSourcescheduler
- the Scheduler where the replay is observedConnectableObservable
that shares a single subscription to the source ObservableSource, replaying all items@CheckReturnValue@SchedulerSupport(value="none")public final ConnectableObservable<T> replay(int bufferSize)
ConnectableObservable
that shares a single subscription to the source ObservableSource that replays at mostbufferSize
items emitted by that ObservableSource. A Connectable ObservableSource resembles an ordinary ObservableSource, 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.
replay
does not operate by default on a particularScheduler
.bufferSize
- the buffer size that limits the number of items that can be replayedConnectableObservable
that shares a single subscription to the source ObservableSource and replays at mostbufferSize
items emitted by that ObservableSource@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final ConnectableObservable<T> replay(int bufferSize, long time,TimeUnit unit)
ConnectableObservable
that shares a single subscription to the source ObservableSource and replays at mostbufferSize
items that were emitted during a specified time window. A Connectable ObservableSource resembles an ordinary ObservableSource, 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.
replay
operates by default on thecomputation
Scheduler
.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
ConnectableObservable
that shares a single subscription to the source ObservableSource and replays at mostbufferSize
items that were emitted during the window defined bytime
@CheckReturnValue@SchedulerSupport(value="custom")public final ConnectableObservable<T> replay(int bufferSize, long time,TimeUnit unit,Scheduler scheduler)
ConnectableObservable
that shares a single subscription to the source ObservableSource and that replays a maximum ofbufferSize
items that are emitted within a specified time window. A Connectable ObservableSource resembles an ordinary ObservableSource, 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.
Scheduler
this operator will use.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 windowConnectableObservable
that shares a single subscription to the source ObservableSource and replays at mostbufferSize
items that were emitted during the window defined bytime
IllegalArgumentException
- ifbufferSize
is less than zero@CheckReturnValue@SchedulerSupport(value="custom")public final ConnectableObservable<T> replay(int bufferSize,Scheduler scheduler)
ConnectableObservable
that shares a single subscription to the source ObservableSource and replays at mostbufferSize
items emitted by that ObservableSource. A Connectable ObservableSource resembles an ordinary ObservableSource, 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.
Scheduler
this operator will use.bufferSize
- the buffer size that limits the number of items that can be replayedscheduler
- the scheduler on which the Observers will observe the emitted itemsConnectableObservable
that shares a single subscription to the source ObservableSource and replays at mostbufferSize
items that were emitted by the ObservableSource@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final ConnectableObservable<T> replay(long time,TimeUnit unit)
ConnectableObservable
that shares a single subscription to the source ObservableSource and replays all items emitted by that ObservableSource within a specified time window. A Connectable ObservableSource resembles an ordinary ObservableSource, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.replay
operates by default on thecomputation
Scheduler
.time
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
ConnectableObservable
that shares a single subscription to the source ObservableSource and replays the items that were emitted during the window defined bytime
@CheckReturnValue@SchedulerSupport(value="custom")public final ConnectableObservable<T> replay(long time,TimeUnit unit,Scheduler scheduler)
ConnectableObservable
that shares a single subscription to the source ObservableSource and replays all items emitted by that ObservableSource within a specified time window. A Connectable ObservableSource resembles an ordinary ObservableSource, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.Scheduler
this operator will use.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 windowConnectableObservable
that shares a single subscription to the source ObservableSource and replays the items that were emitted during the window defined bytime
@CheckReturnValue@SchedulerSupport(value="custom")public final ConnectableObservable<T> replay(Scheduler scheduler)
ConnectableObservable
that shares a single subscription to the source ObservableSource that will replay all of its items and notifications to any futureObserver
on the givenScheduler
. A Connectable ObservableSource resembles an ordinary ObservableSource, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.Scheduler
this operator will use.scheduler
- the Scheduler on which the Observers will observe the emitted itemsConnectableObservable
that shares a single subscription to the source ObservableSource that will replay all of its items and notifications to any futureObserver
on the givenScheduler
@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> retry()
onError
(infinite retry count). If the source ObservableSource callsObserver.onError(java.lang.Throwable)
, this method will resubscribe to the source ObservableSource rather than propagating theonError
call.
Any and all items emitted by the source ObservableSource will be emitted by the resulting ObservableSource, even those emitted during failed subscriptions. For example, if an ObservableSource 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]
.
retry
does not operate by default on a particularScheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> retry(BiPredicate<? superInteger,? superThrowable> predicate)
onError
and the predicate returns true for that specific exception and retry count.retry
does not operate by default on a particularScheduler
.predicate
- the predicate that determines if a resubscription may happen in case of a specific exception and retry countretry()
,ReactiveX operators documentation: Retry@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> retry(long times)
onError
up to a specified number of retries. If the source ObservableSource callsObserver.onError(java.lang.Throwable)
, this method will resubscribe to the source ObservableSource for a maximum ofcount
resubscriptions rather than propagating theonError
call.
Any and all items emitted by the source ObservableSource will be emitted by the resulting ObservableSource, even those emitted during failed subscriptions. For example, if an ObservableSource 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]
.
retry
does not operate by default on a particularScheduler
.times
- the number of times to resubscribe if the current Observable fails@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> retry(long times,Predicate<? superThrowable> predicate)
retry
does not operate by default on a particularScheduler
.times
- the number of times to resubscribe if the current Observable failspredicate
- the predicate called with the failure Throwable and should return true to trigger a retry.@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> retry(Predicate<? superThrowable> predicate)
retry
does not operate by default on a particularScheduler
.predicate
- the predicate that receives the failure Throwable and should return true to trigger a retry.@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> retryUntil(BooleanSupplier stop)
retryUntil
does not operate by default on a particularScheduler
.stop
- the function that should return true to stop retrying@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> retryWhen(Function<? superObservable<Throwable>,? extendsObservableSource<?>> handler)
onError
. AnonError
notification from the source will result in the emission of aThrowable
item to the ObservableSource provided as an argument to thenotificationHandler
function. If that ObservableSource callsonComplete
oronError
thenretry
will callonComplete
oronError
on the child subscription. Otherwise, this ObservableSource will resubscribe to the source ObservableSource.Example: This retries 3 times, each time incrementing the number of seconds it waits.
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);
Output is: 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 innerObservableSource
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, signalling onNext followed by onComplete 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);
retryWhen
does not operate by default on a particularScheduler
.handler
- receives an ObservableSource of notifications with which a user can complete or error, aborting the retry@SchedulerSupport(value="none")public final void safeSubscribe(Observer<? superT> observer)
safeSubscribe
does not operate by default on a particularScheduler
.observer
- the incoming Observer instanceNullPointerException
- if s is null@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<T> sample(long period,TimeUnit unit)
sample
operates by default on thecomputation
Scheduler
.period
- the sampling rateunit
- theTimeUnit
in whichperiod
is definedthrottleLast(long, TimeUnit)
@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<T> sample(long period,TimeUnit unit, boolean emitLast)
sample
operates by default on thecomputation
Scheduler
.History: 2.0.5 - experimental
period
- the sampling rateunit
- theTimeUnit
in whichperiod
is definedemitLast
- if true and the upstream completes while there is still an unsampled item available, that item is emitted to downstream before completion if false, an unsampled last item is ignored.throttleLast(long, TimeUnit)
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> sample(long period,TimeUnit unit,Scheduler scheduler)
Scheduler
this operator will use.period
- the sampling rateunit
- theTimeUnit
in whichperiod
is definedscheduler
- theScheduler
to use when samplingthrottleLast(long, TimeUnit, Scheduler)
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> sample(long period,TimeUnit unit,Scheduler scheduler, boolean emitLast)
Scheduler
this operator will use.History: 2.0.5 - experimental
period
- the sampling rateunit
- theTimeUnit
in whichperiod
is definedscheduler
- theScheduler
to use when samplingemitLast
- if true and the upstream completes while there is still an unsampled item available, that item is emitted to downstream before completion if false, an unsampled last item is ignored.throttleLast(long, TimeUnit, Scheduler)
@CheckReturnValue@SchedulerSupport(value="none")public final <U> Observable<T> sample(ObservableSource<U> sampler)
sampler
ObservableSource emits an item or completes, emits the most recently emitted item (if any) emitted by the source ObservableSource since the previous emission from thesampler
ObservableSource.sample
does not operate by default on a particularScheduler
.U
- the element type of the sampler ObservableSourcesampler
- the ObservableSource to use for sampling the source ObservableSourcesampler
ObservableSource emits an item or completes@CheckReturnValue@SchedulerSupport(value="none")public final <U> Observable<T> sample(ObservableSource<U> sampler, boolean emitLast)
sampler
ObservableSource emits an item or completes, emits the most recently emitted item (if any) emitted by the source ObservableSource since the previous emission from thesampler
ObservableSource and optionally emit the very last upstream item when the upstream or other ObservableSource complete.sample
does not operate by default on a particularScheduler
.History: 2.0.5 - experimental
U
- the element type of the sampler ObservableSourcesampler
- the ObservableSource to use for sampling the source ObservableSourceemitLast
- if true and the upstream completes while there is still an unsampled item available, that item is emitted to downstream before completion if false, an unsampled last item is ignored.sampler
ObservableSource emits an item or completes@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> scan(BiFunction<T,T,T> accumulator)
This sort of function is sometimes called an accumulator.
scan
does not operate by default on a particularScheduler
.accumulator
- an accumulator function to be invoked on each item emitted by the source ObservableSource, whose result will be emitted toObserver
s viaonNext
and used in the next accumulator call@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> scan(R initialValue,BiFunction<R,? superT,R> accumulator)
This sort of function is sometimes called an accumulator.
Note that the ObservableSource that results from this method will emitinitialValue
as its first emitted item.
Note that theinitialValue
is shared among all subscribers to the resulting ObservableSource and may cause problems if it is mutable. To make sure each subscriber gets its own value, defer the application of this operator viadefer(Callable)
:
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))) );
scan
does not operate by default on a particularScheduler
.R
- the initial, accumulator and result typeinitialValue
- the initial (seed) accumulator itemaccumulator
- an accumulator function to be invoked on each item emitted by the source ObservableSource, whose result will be emitted toObserver
s viaonNext
and used in the next accumulator callinitialValue
followed by the results of each call to the accumulator function@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> scanWith(Callable<R> seedSupplier,BiFunction<R,? superT,R> accumulator)
This sort of function is sometimes called an accumulator.
Note that the ObservableSource that results from this method will emit the value returned by theseedSupplier
as its first item.
scanWith
does not operate by default on a particularScheduler
.R
- the initial, accumulator and result typeseedSupplier
- a Callable that returns the initial (seed) accumulator item for each individual Observeraccumulator
- an accumulator function to be invoked on each item emitted by the source ObservableSource, whose result will be emitted toObserver
s viaonNext
and used in the next accumulator callinitialValue
followed by the results of each call to the accumulator function@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> serialize()
It is possible for an ObservableSource to invoke its Observers' methods asynchronously, perhaps from different threads. This could make such an ObservableSource 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 an ObservableSource to be well-behaved and sequential by applying theserialize
method to it.
serialize
does not operate by default on a particularScheduler
.ObservableSource
that is guaranteed to be well-behaved and to make only serialized calls to its observers@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> share()
ObservableSource
that multicasts (and shares a single subscription to) the originalObservableSource
. As long as there is at least oneObserver
thisObservableSource
will be subscribed and emitting data. When all subscribers have disposed it will dispose the sourceObservableSource
. This is an alias forpublish()
.refCount()
.
share
does not operate by default on a particularScheduler
.ObservableSource
that upon connection causes the sourceObservableSource
to emit items to itsObserver
s@CheckReturnValue@SchedulerSupport(value="none")public final Maybe<T> singleElement()
IllegalArgumentException
if this Observable emits more than one item.singleElement
does not operate by default on a particularScheduler
.Maybe
that emits the single item emitted by the source ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final Single<T> single(T defaultItem)
IllegalArgumentException
is signalled instead.single
does not operate by default on a particularScheduler
.defaultItem
- a default value to emit if the source ObservableSource emits no item@CheckReturnValue@SchedulerSupport(value="none")public final Single<T> singleOrError()
NoSuchElementException
orIllegalArgumentException
will be signalled respectively.singleOrError
does not operate by default on a particularScheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> skip(long count)
count
items emitted by the source ObservableSource and emits the remainder.skip
does not operate by default on a particularScheduler
.count
- the number of items to skipcount
items that the source ObservableSource emits@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<T> skip(long time,TimeUnit unit)
skip
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.time
- the length of the time window to skipunit
- the time unit oftime
time
elapses and the emits the remainder@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> skip(long time,TimeUnit unit,Scheduler scheduler)
Scheduler
elapses.Scheduler
this operator will use for the timed skippingtime
- the length of the time window to skipunit
- the time unit oftime
scheduler
- theScheduler
on which the timed wait happenstime
andscheduler
elapses, and then emits the remainder@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> skipLast(int count)
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 returned ObservableSource. This causes such items to be delayed.
skipLast
does not operate by default on a particularScheduler
.count
- number of items to drop from the end of the source sequenceIndexOutOfBoundsException
- ifcount
is less than zero@CheckReturnValue@SchedulerSupport(value="io.reactivex:trampoline")public final Observable<T> skipLast(long time,TimeUnit unit)
Note: this action will cache the latest items arriving in the specified time window.
skipLast
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.time
- the length of the time windowunit
- the time unit oftime
time
@CheckReturnValue@SchedulerSupport(value="io.reactivex:trampoline")public final Observable<T> skipLast(long time,TimeUnit unit, boolean delayError)
Note: this action will cache the latest items arriving in the specified time window.
skipLast
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.time
- the length of the time windowunit
- the time unit oftime
delayError
- if true, an exception signalled by the current Observable is delayed until the regular elements are consumed by the downstream; if false, an exception is immediately signalled and all regular elements droppedtime
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> skipLast(long time,TimeUnit unit,Scheduler scheduler)
Note: this action will cache the latest items arriving in the specified time window.
Scheduler
this operator will use for tracking the current timetime
- the length of the time windowunit
- the time unit oftime
scheduler
- the scheduler used as the time sourcetime
andscheduler
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> skipLast(long time,TimeUnit unit,Scheduler scheduler, boolean delayError)
Note: this action will cache the latest items arriving in the specified time window.
Scheduler
this operator will use to track the current timetime
- the length of the time windowunit
- the time unit oftime
scheduler
- the scheduler used as the time sourcedelayError
- if true, an exception signalled by the current Observable is delayed until the regular elements are consumed by the downstream; if false, an exception is immediately signalled and all regular elements droppedtime
andscheduler
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> skipLast(long time,TimeUnit unit,Scheduler scheduler, boolean delayError, int bufferSize)
Note: this action will cache the latest items arriving in the specified time window.
Scheduler
this operator will use.time
- the length of the time windowunit
- the time unit oftime
scheduler
- the scheduler used as the time sourcedelayError
- if true, an exception signalled by the current Observable is delayed until the regular elements are consumed by the downstream; if false, an exception is immediately signalled and all regular elements droppedbufferSize
- the hint about how many elements to expect to be skippedtime
andscheduler
@CheckReturnValue@SchedulerSupport(value="none")public final <U> Observable<T> skipUntil(ObservableSource<U> other)
skipUntil
does not operate by default on a particularScheduler
.U
- the element type of the other ObservableSourceother
- the second ObservableSource that has to emit an item before the source ObservableSource's elements begin to be mirrored by the resulting ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> skipWhile(Predicate<? superT> predicate)
skipWhile
does not operate by default on a particularScheduler
.predicate
- a function to test each item emitted from the source ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> sorted()
Comparable
with respect to all other items in the sequence. If any item emitted by this Observable does not implementComparable
with respect to all other items emitted by this Observable, no items will be emitted and the sequence is terminated with aClassCastException
.
Note that callingsorted
with long, non-terminating or infinite sources might causeOutOfMemoryError
sorted
does not operate by default on a particularScheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> sorted(Comparator<? superT> sortFunction)
Note that callingsorted
with long, non-terminating or infinite sources might causeOutOfMemoryError
sorted
does not operate by default on a particularScheduler
.sortFunction
- a function that compares two items emitted by the source ObservableSource and returns an Integer that indicates their sort order@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> startWith(Iterable<? extendsT> items)
Iterable
before it begins to emit items emitted by the source ObservableSource.startWith
does not operate by default on a particularScheduler
.items
- an Iterable that contains the items you want the modified ObservableSource to emit firstIterable
and then emits the items emitted by the source ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> startWith(ObservableSource<? extendsT> other)
ObservableSource
before it begins to emit items emitted by the source ObservableSource.startWith
does not operate by default on a particularScheduler
.other
- an ObservableSource that contains the items you want the modified ObservableSource to emit firstObservableSource
and then emits the items emitted by the source ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> startWith(T item)
startWith
does not operate by default on a particularScheduler
.item
- the item to emit first@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> startWithArray(T... items)
startWithArray
does not operate by default on a particularScheduler
.items
- the array of values to emit first@SchedulerSupport(value="none")public final Disposable subscribe()
onNext
andonComplete
emissions. If the Observable emits an error, it is wrapped into anOnErrorNotImplementedException
and routed to the RxJavaPlugins.onError handler.
subscribe
does not operate by default on a particularScheduler
.Disposable
reference with which the caller can stop receiving items before the ObservableSource has finished sending them@CheckReturnValue@SchedulerSupport(value="none")public final Disposable subscribe(Consumer<? superT> onNext)
If the Observable emits an error, it is wrapped into anOnErrorNotImplementedException
and routed to the RxJavaPlugins.onError handler.
subscribe
does not operate by default on a particularScheduler
.onNext
- theConsumer<T>
you have designed to accept emissions from the ObservableSourceDisposable
reference with which the caller can stop receiving items before the ObservableSource has finished sending themNullPointerException
- ifonNext
is null@CheckReturnValue@SchedulerSupport(value="none")public final Disposable subscribe(Consumer<? superT> onNext,Consumer<? superThrowable> onError)
subscribe
does not operate by default on a particularScheduler
.onNext
- theConsumer<T>
you have designed to accept emissions from the ObservableSourceonError
- theConsumer<Throwable>
you have designed to accept any error notification from the ObservableSourceDisposable
reference with which the caller can stop receiving items before the ObservableSource has finished sending themNullPointerException
- ifonNext
is null, or ifonError
is null@CheckReturnValue@SchedulerSupport(value="none")public final Disposable subscribe(Consumer<? superT> onNext,Consumer<? superThrowable> onError,Action onComplete)
subscribe
does not operate by default on a particularScheduler
.onNext
- theConsumer<T>
you have designed to accept emissions from the ObservableSourceonError
- theConsumer<Throwable>
you have designed to accept any error notification from the ObservableSourceonComplete
- theAction
you have designed to accept a completion notification from the ObservableSourceDisposable
reference with which the caller can stop receiving items before the ObservableSource has finished sending themNullPointerException
- ifonNext
is null, or ifonError
is null, or ifonComplete
is null@CheckReturnValue@SchedulerSupport(value="none")public final Disposable subscribe(Consumer<? superT> onNext,Consumer<? superThrowable> onError,Action onComplete,Consumer<? superDisposable> onSubscribe)
subscribe
does not operate by default on a particularScheduler
.onNext
- theConsumer<T>
you have designed to accept emissions from the ObservableSourceonError
- theConsumer<Throwable>
you have designed to accept any error notification from the ObservableSourceonComplete
- theAction
you have designed to accept a completion notification from the ObservableSourceonSubscribe
- theConsumer
that receives the upstream's DisposableDisposable
reference with which the caller can stop receiving items before the ObservableSource has finished sending themNullPointerException
- ifonNext
is null, or ifonError
is null, or ifonComplete
is null, or ifonSubscribe
is null@SchedulerSupport(value="none")public final void subscribe(Observer<? superT> observer)
ObservableSource
subscribe
in interface ObservableSource<T>
observer
- the Observer, not nullprotected abstract void subscribeActual(Observer<? superT> observer)
Observer
s.There is no need to call any of the plugin hooks on the currentObservable
instance or theObserver
; all hooks and basic safeguards have been applied bysubscribe(Observer)
before this method gets called.
observer
- the incoming Observer, never null@CheckReturnValue@SchedulerSupport(value="none")public final <E extendsObserver<? superT>> E subscribeWith(E observer)
Usage example:
Observable<Integer> source = Observable.range(1, 10); CompositeDisposable composite = new CompositeDisposable(); DisposableObserver<Integer> ds = new DisposableObserver<>() { // ... }; composite.add(source.subscribeWith(ds));
subscribeWith
does not operate by default on a particularScheduler
.E
- the type of the Observer to use and returnobserver
- the Observer (subclass) to use and return, not nullobserver
NullPointerException
- ifobserver
is null@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> subscribeOn(Scheduler scheduler)
Scheduler
.Scheduler
this operator will use.scheduler
- theScheduler
to perform subscription actions onScheduler
observeOn(io.reactivex.Scheduler)
@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> switchIfEmpty(ObservableSource<? extendsT> other)
switchIfEmpty
does not operate by default on a particularScheduler
.other
- the alternate ObservableSource to subscribe to if the source does not emit any items@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> switchMap(Function<? superT,? extendsObservableSource<? extends R>> mapper)
The resulting ObservableSource completes if both the upstream ObservableSource and the last inner ObservableSource, if any, complete. If the upstream ObservableSource signals an onError, the inner ObservableSource is disposed and the error delivered in-sequence.
switchMap
does not operate by default on a particularScheduler
.R
- the element type of the inner ObservableSources and the outputmapper
- a function that, when applied to an item emitted by the source ObservableSource, returns an ObservableSourcefunc
to the most recently emitted item emitted by the source ObservableSourceswitchMapDelayError(Function)
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> switchMap(Function<? superT,? extendsObservableSource<? extends R>> mapper, int bufferSize)
The resulting ObservableSource completes if both the upstream ObservableSource and the last inner ObservableSource, if any, complete. If the upstream ObservableSource signals an onError, the inner ObservableSource is disposed and the error delivered in-sequence.
switchMap
does not operate by default on a particularScheduler
.R
- the element type of the inner ObservableSources and the outputmapper
- a function that, when applied to an item emitted by the source ObservableSource, returns an ObservableSourcebufferSize
- the number of elements to prefetch from the current active inner ObservableSourcefunc
to the most recently emitted item emitted by the source ObservableSourceswitchMapDelayError(Function, int)
@CheckReturnValue@SchedulerSupport(value="none")public final Completable switchMapCompletable(@NonNullFunction<? superT,? extendsCompletableSource> mapper)
CompletableSource
s, subscribes to the newer one while disposing the subscription to the previousCompletableSource
, thus keeping at most one activeCompletableSource
running. Since aCompletableSource
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
.
switchMapCompletable
does not operate by default on a particularScheduler
.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 signalled to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors.History: 2.1.11 - experimental
mapper
- the function called with each upstream item and should return aCompletableSource
to be subscribed to and awaited for (non blockingly) for its terminal eventswitchMapCompletableDelayError(Function)
@CheckReturnValue@SchedulerSupport(value="none")public final Completable switchMapCompletableDelayError(@NonNullFunction<? superT,? extendsCompletableSource> mapper)
CompletableSource
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 aCompletableSource
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
.
switchMapCompletableDelayError
does not operate by default on a particularScheduler
.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 signalled to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors.History: 2.1.11 - experimental
mapper
- the function called with each upstream item and should return aCompletableSource
to be subscribed to and awaited for (non blockingly) for its terminal eventswitchMapCompletable(Function)
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> switchMapMaybe(@NonNullFunction<? superT,? extendsMaybeSource<? extends R>> mapper)
MaybeSource
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 thisObservable
or any of the active innerMaybeSource
s fail.switchMapMaybe
does not operate by default on a particularScheduler
.onError
if thisObservable
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 thisObservable
or from any of the innerMaybeSource
s will be forwarded to the global error handler viaRxJavaPlugins.onError(Throwable)
asUndeliverableException
History: 2.1.11 - experimental
R
- the output value typemapper
- the function called with the current upstream event and should return aMaybeSource
to replace the current active inner source and get subscribed to.switchMapMaybeDelayError(Function)
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> switchMapMaybeDelayError(@NonNullFunction<? superT,? extendsMaybeSource<? extends R>> mapper)
MaybeSource
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 thisObservable
or the innerMaybeSource
s until all terminate.switchMapMaybeDelayError
does not operate by default on a particularScheduler
.History: 2.1.11 - experimental
R
- the output value typemapper
- the function called with the current upstream event and should return aMaybeSource
to replace the current active inner source and get subscribed to.switchMapMaybe(Function)
@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final <R> Observable<R> switchMapSingle(@NonNullFunction<? superT,? extendsSingleSource<? extends R>> mapper)
The resulting ObservableSource completes if both the upstream ObservableSource and the last inner SingleSource, if any, complete. If the upstream ObservableSource signals an onError, the inner SingleSource is disposed and the error delivered in-sequence.
switchMapSingle
does not operate by default on a particularScheduler
.History: 2.0.8 - experimental
R
- the element type of the inner SingleSources and the outputmapper
- a function that, when applied to an item emitted by the source ObservableSource, returns a SingleSourcefunc
to the most recently emitted item emitted by the source ObservableSourceswitchMapSingleDelayError(Function)
@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final <R> Observable<R> switchMapSingleDelayError(@NonNullFunction<? superT,? extendsSingleSource<? extends R>> mapper)
The resulting ObservableSource completes if both the upstream ObservableSource and the last inner SingleSource, if any, complete. If the upstream ObservableSource signals an onError, the termination of the last inner SingleSource will emit that error as is or wrapped into a CompositeException along with the other possible errors the former inner SingleSources signalled.
switchMapSingleDelayError
does not operate by default on a particularScheduler
.History: 2.0.8 - experimental
R
- the element type of the inner SingleSources and the outputmapper
- a function that, when applied to an item emitted by the source ObservableSource, returns a SingleSourcefunc
to the most recently emitted item emitted by the source ObservableSourceswitchMapSingle(Function)
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> switchMapDelayError(Function<? superT,? extendsObservableSource<? extends R>> mapper)
The resulting ObservableSource completes if both the upstream ObservableSource and the last inner ObservableSource, if any, complete. If the upstream ObservableSource signals an onError, the termination of the last inner ObservableSource will emit that error as is or wrapped into a CompositeException along with the other possible errors the former inner ObservableSources signalled.
switchMapDelayError
does not operate by default on a particularScheduler
.R
- the element type of the inner ObservableSources and the outputmapper
- a function that, when applied to an item emitted by the source ObservableSource, returns an ObservableSourcefunc
to the most recently emitted item emitted by the source ObservableSourceswitchMap(Function)
@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> switchMapDelayError(Function<? superT,? extendsObservableSource<? extends R>> mapper, int bufferSize)
The resulting ObservableSource completes if both the upstream ObservableSource and the last inner ObservableSource, if any, complete. If the upstream ObservableSource signals an onError, the termination of the last inner ObservableSource will emit that error as is or wrapped into a CompositeException along with the other possible errors the former inner ObservableSources signalled.
switchMapDelayError
does not operate by default on a particularScheduler
.R
- the element type of the inner ObservableSources and the outputmapper
- a function that, when applied to an item emitted by the source ObservableSource, returns an ObservableSourcebufferSize
- the number of elements to prefetch from the current active inner ObservableSourcefunc
to the most recently emitted item emitted by the source ObservableSourceswitchMap(Function, int)
@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> take(long count)
count
items emitted by the source ObservableSource. If the source emits fewer thancount
items then all of its items are emitted. This method returns an ObservableSource that will invoke a subscribingObserver
'sonNext
function a maximum ofcount
times before invokingonComplete
.
take
does not operate by default on a particularScheduler
.count
- the maximum number of items to emitcount
items emitted by the source ObservableSource, or all of the items from the source ObservableSource if that ObservableSource emits fewer thancount
items@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> take(long time,TimeUnit unit)
If time runs out before theObservable
completes normally, theonComplete
event will be signaled on the defaultcomputation
Scheduler
.
take
operates by default on thecomputation
Scheduler
.time
- the length of the time windowunit
- the time unit oftime
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> take(long time,TimeUnit unit,Scheduler scheduler)
If time runs out before theObservable
completes normally, theonComplete
event will be signaled on the providedScheduler
.
Scheduler
this operator will use.time
- the length of the time windowunit
- the time unit oftime
scheduler
- the Scheduler used for time source@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> takeLast(int count)
count
items emitted by the source ObservableSource. If the source emits fewer thancount
items then all of its items are emitted.takeLast
does not operate by default on a particularScheduler
.count
- the maximum number of items to emit from the end of the sequence of items emitted by the source ObservableSourcecount
items emitted by the source ObservableSourceIndexOutOfBoundsException
- ifcount
is less than zero@CheckReturnValue@SchedulerSupport(value="io.reactivex:trampoline")public final Observable<T> takeLast(long count, long time,TimeUnit unit)
takeLast
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.count
- the maximum number of items to emittime
- the length of the time windowunit
- the time unit oftime
count
items from the source ObservableSource that were emitted in a specified window of time before the ObservableSource completed@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> takeLast(long count, long time,TimeUnit unit,Scheduler scheduler)
Scheduler
this operator will use for tracking the current timecount
- 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 itemscount
items from the source ObservableSource that were emitted in a specified window of time before the ObservableSource completed, where the timing information is provided by the givenscheduler
IndexOutOfBoundsException
- ifcount
is less than zero@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> takeLast(long count, long time,TimeUnit unit,Scheduler scheduler, boolean delayError, int bufferSize)
Scheduler
this operator will use for tracking the current timecount
- 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
- if true, an exception signalled by the current Observable is delayed until the regular elements are consumed by the downstream; if false, an exception is immediately signalled and all regular elements droppedbufferSize
- the hint about how many elements to expect to be lastcount
items from the source ObservableSource that were emitted in a specified window of time before the ObservableSource completed, where the timing information is provided by the givenscheduler
IndexOutOfBoundsException
- ifcount
is less than zero@CheckReturnValue@SchedulerSupport(value="io.reactivex:trampoline")public final Observable<T> takeLast(long time,TimeUnit unit)
takeLast
operates by default on thecomputation
Scheduler
.time
- the length of the time windowunit
- the time unit oftime
time
@CheckReturnValue@SchedulerSupport(value="io.reactivex:trampoline")public final Observable<T> takeLast(long time,TimeUnit unit, boolean delayError)
takeLast
operates by default on thecomputation
Scheduler
.time
- the length of the time windowunit
- the time unit oftime
delayError
- if true, an exception signalled by the current Observable is delayed until the regular elements are consumed by the downstream; if false, an exception is immediately signalled and all regular elements droppedtime
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> takeLast(long time,TimeUnit unit,Scheduler scheduler)
Scheduler
this operator will use.time
- the length of the time windowunit
- the time unit oftime
scheduler
- the Scheduler that provides the timestamps for the Observed itemstime
, where the timing information is provided byscheduler
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> takeLast(long time,TimeUnit unit,Scheduler scheduler, boolean delayError)
Scheduler
this operator will use.time
- the length of the time windowunit
- the time unit oftime
scheduler
- the Scheduler that provides the timestamps for the Observed itemsdelayError
- if true, an exception signalled by the current Observable is delayed until the regular elements are consumed by the downstream; if false, an exception is immediately signalled and all regular elements droppedtime
, where the timing information is provided byscheduler
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> takeLast(long time,TimeUnit unit,Scheduler scheduler, boolean delayError, int bufferSize)
Scheduler
this operator will use.time
- the length of the time windowunit
- the time unit oftime
scheduler
- the Scheduler that provides the timestamps for the Observed itemsdelayError
- if true, an exception signalled by the current Observable is delayed until the regular elements are consumed by the downstream; if false, an exception is immediately signalled and all regular elements droppedbufferSize
- the hint about how many elements to expect to be lasttime
, where the timing information is provided byscheduler
@CheckReturnValue@SchedulerSupport(value="none")public final <U> Observable<T> takeUntil(ObservableSource<U> other)
takeUntil
does not operate by default on a particularScheduler
.U
- the type of items emitted byother
other
- the ObservableSource whose first emitted item will causetakeUntil
to stop emitting items from the source Observableother
emits its first item@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> takeUntil(Predicate<? superT> stopPredicate)
The difference between this operator andtakeWhile(Predicate)
is that here, the condition is evaluatedafter the item is emitted.
takeUntil
does not operate by default on a particularScheduler
.stopPredicate
- a function that evaluates an item emitted by the source Observable and returns a BooleantakeWhile(Predicate)
@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> takeWhile(Predicate<? superT> predicate)
takeWhile
does not operate by default on a particularScheduler
.predicate
- a function that evaluates an item emitted by the source ObservableSource and returns a Booleanpredicate
, then completestakeUntil(Predicate)
@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<T> throttleFirst(long windowDuration,TimeUnit unit)
This differs fromthrottleLast(long, java.util.concurrent.TimeUnit)
in that this only tracks passage of time whereasthrottleLast(long, java.util.concurrent.TimeUnit)
ticks at scheduled intervals.
throttleFirst
operates by default on thecomputation
Scheduler
.windowDuration
- time to wait before emitting another item after emitting the last itemunit
- the unit of time ofwindowDuration
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> throttleFirst(long skipDuration,TimeUnit unit,Scheduler scheduler)
This differs fromthrottleLast(long, java.util.concurrent.TimeUnit)
in that this only tracks passage of time whereasthrottleLast(long, java.util.concurrent.TimeUnit)
ticks at scheduled intervals.
Scheduler
this operator will use.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@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<T> throttleLast(long intervalDuration,TimeUnit unit)
This differs fromthrottleFirst(long, java.util.concurrent.TimeUnit)
in that this ticks along at a scheduled interval whereasthrottleFirst(long, java.util.concurrent.TimeUnit)
does not tick, it just tracks passage of time.
throttleLast
operates by default on thecomputation
Scheduler
.intervalDuration
- duration of windows within which the last item emitted by the source ObservableSource will be emittedunit
- the unit of time ofintervalDuration
sample(long, TimeUnit)
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> throttleLast(long intervalDuration,TimeUnit unit,Scheduler scheduler)
This differs fromthrottleFirst(long, java.util.concurrent.TimeUnit)
in that this ticks along at a scheduled interval whereasthrottleFirst(long, java.util.concurrent.TimeUnit)
does not tick, it just tracks passage of time.
Scheduler
this operator will use.intervalDuration
- duration of windows within which the last item emitted by the source ObservableSource will be emittedunit
- the unit of time ofintervalDuration
scheduler
- theScheduler
to use internally to manage the timers that handle timeout for each eventsample(long, TimeUnit, Scheduler)
@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<T> throttleLatest(long timeout,TimeUnit unit)
Observable
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 withthrottleLatest(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.
throttleLatest
operates by default on thecomputation
Scheduler
.History: 2.1.14 - experimental
timeout
- the time to wait after an item emission towards the downstream before trying to emit the latest item from upstream againunit
- the time unitthrottleLatest(long, TimeUnit, boolean)
,throttleLatest(long, TimeUnit, Scheduler)
@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<T> throttleLatest(long timeout,TimeUnit unit, boolean emitLast)
Observable
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.
throttleLatest
operates by default on thecomputation
Scheduler
.History: 2.1.14 - experimental
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.throttleLatest(long, TimeUnit, Scheduler, boolean)
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> throttleLatest(long timeout,TimeUnit unit,Scheduler scheduler)
Observable
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 withthrottleLatest(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
this operator will use.History: 2.1.14 - experimental
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 performedthrottleLatest(long, TimeUnit, Scheduler, boolean)
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> throttleLatest(long timeout,TimeUnit unit,Scheduler scheduler, boolean emitLast)
Observable
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
this operator will use.History: 2.1.14 - experimental
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.@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<T> throttleWithTimeout(long timeout,TimeUnit unit)
debounce(long, TimeUnit, Scheduler)
).Note: If items keep being emitted by the source ObservableSource faster than the timeout then no items will be emitted by the resulting ObservableSource.
throttleWithTimeout
operates by default on thecomputation
Scheduler
.timeout
- the length of the window of time that must pass after the emission of an item from the source ObservableSource in which that ObservableSource emits no items in order for the item to be emitted by the resulting ObservableSourceunit
- the unit of time for the specifiedtimeout
debounce(long, TimeUnit)
@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> throttleWithTimeout(long timeout,TimeUnit unit,Scheduler scheduler)
debounce(long, TimeUnit, Scheduler)
).Note: If items keep being emitted by the source ObservableSource faster than the timeout then no items will be emitted by the resulting ObservableSource.
Scheduler
this operator will use.timeout
- the length of the window of time that must pass after the emission of an item from the source ObservableSource in which that ObservableSource emits no items in order for the item to be emitted by the resulting ObservableSourceunit
- the unit of time for the specifiedtimeout
scheduler
- theScheduler
to use internally to manage the timers that handle the timeout for each itemdebounce(long, TimeUnit, Scheduler)
@CheckReturnValue@SchedulerSupport(value="none")public final Observable<Timed<T>> timeInterval()
timeInterval
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final Observable<Timed<T>> timeInterval(Scheduler scheduler)
Scheduler
.scheduler
- theScheduler
used to compute time intervals@CheckReturnValue@SchedulerSupport(value="none")public final Observable<Timed<T>> timeInterval(TimeUnit unit)
timeInterval
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.unit
- the time unit for the current time@CheckReturnValue@SchedulerSupport(value="none")public final Observable<Timed<T>> timeInterval(TimeUnit unit,Scheduler scheduler)
Scheduler
.unit
- the time unit for the current timescheduler
- theScheduler
used to compute time intervals@CheckReturnValue@SchedulerSupport(value="none")public final <V> Observable<T> timeout(Function<? superT,? extendsObservableSource<V>> itemTimeoutIndicator)
TimeoutException
if an item emitted by the source ObservableSource doesn't arrive within a window of time after the emission of the previous item, where that period of time is measured by an ObservableSource that is a function of the previous item.Note: The arrival of the first source item is never timed out.
timeout
operates by default on theimmediate
Scheduler
.V
- the timeout value type (ignored)itemTimeoutIndicator
- a function that returns an ObservableSource for each item emitted by the source ObservableSource and that determines the timeout window for the subsequent itemTimeoutException
if an item emitted by the source ObservableSource takes longer to arrive than the time window defined by the selector for the previously emitted item@CheckReturnValue@SchedulerSupport(value="none")public final <V> Observable<T> timeout(Function<? superT,? extendsObservableSource<V>> itemTimeoutIndicator,ObservableSource<? extendsT> other)
Note: The arrival of the first source item is never timed out.
timeout
operates by default on theimmediate
Scheduler
.V
- the timeout value type (ignored)itemTimeoutIndicator
- a function that returns an ObservableSource, for each item emitted by the source ObservableSource, that determines the timeout window for the subsequent itemother
- the fallback ObservableSource to switch to if the source ObservableSource times out@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<T> timeout(long timeout,TimeUnit timeUnit)
TimeoutException
.timeout
operates by default on thecomputation
Scheduler
.timeout
- maximum duration between emitted items before a timeout occurstimeUnit
- the unit of time that applies to thetimeout
argument.TimeoutException
in case of a timeout@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<T> timeout(long timeout,TimeUnit timeUnit,ObservableSource<? extendsT> other)
timeout
operates by default on thecomputation
Scheduler
.timeout
- maximum duration between items before a timeout occurstimeUnit
- the unit of time that applies to thetimeout
argumentother
- the fallback ObservableSource to use in case of a timeout@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> timeout(long timeout,TimeUnit timeUnit,Scheduler scheduler,ObservableSource<? extendsT> other)
Scheduler
this operator will use.timeout
- maximum duration between items before a timeout occurstimeUnit
- the unit of time that applies to thetimeout
argumentscheduler
- theScheduler
to run the timeout timers onother
- the ObservableSource to use as the fallback in case of a timeout@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> timeout(long timeout,TimeUnit timeUnit,Scheduler scheduler)
TimeoutException
.Scheduler
this operator will use.timeout
- maximum duration between items before a timeout occurstimeUnit
- the unit of time that applies to thetimeout
argumentscheduler
- the Scheduler to run the timeout timers onTimeoutException
in case of a timeout@CheckReturnValue@SchedulerSupport(value="none")public final <U,V> Observable<T> timeout(ObservableSource<U> firstTimeoutIndicator,Function<? superT,? extendsObservableSource<V>> itemTimeoutIndicator)
TimeoutException
if either the first item emitted by the source ObservableSource or any subsequent item doesn't arrive within time windows defined by other ObservableSources.timeout
operates by default on theimmediate
Scheduler
.U
- the first timeout value type (ignored)V
- the subsequent timeout value type (ignored)firstTimeoutIndicator
- a function that returns an ObservableSource that determines the timeout window for the first source itemitemTimeoutIndicator
- a function that returns an ObservableSource for each item emitted by the source ObservableSource and that determines the timeout window in which the subsequent source item must arrive in order to continue the sequenceTimeoutException
if either the first item or any subsequent item doesn't arrive within the time windows specified by the timeout selectors@CheckReturnValue@SchedulerSupport(value="none")public final <U,V> Observable<T> timeout(ObservableSource<U> firstTimeoutIndicator,Function<? superT,? extendsObservableSource<V>> itemTimeoutIndicator,ObservableSource<? extendsT> other)
timeout
operates by default on theimmediate
Scheduler
.U
- the first timeout value type (ignored)V
- the subsequent timeout value type (ignored)firstTimeoutIndicator
- a function that returns an ObservableSource which determines the timeout window for the first source itemitemTimeoutIndicator
- a function that returns an ObservableSource for each item emitted by the source ObservableSource and that determines the timeout window in which the subsequent source item must arrive in order to continue the sequenceother
- the fallback ObservableSource to switch to if the source ObservableSource times outother
ObservableSource if either the first item emitted by the source ObservableSource or any subsequent item doesn't arrive within time windows defined by the timeout selectorsNullPointerException
- ifitemTimeoutIndicator
is null, or ifother
is null@CheckReturnValue@SchedulerSupport(value="none")public final Observable<Timed<T>> timestamp()
Timed
object.timestamp
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final Observable<Timed<T>> timestamp(Scheduler scheduler)
Timed
object whose timestamps are provided by a specified Scheduler.Scheduler
.scheduler
- theScheduler
to use as a time sourcescheduler
@CheckReturnValue@SchedulerSupport(value="none")public final Observable<Timed<T>> timestamp(TimeUnit unit)
Timed
object.timestamp
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.unit
- the time unit for the current time@CheckReturnValue@SchedulerSupport(value="none")public final Observable<Timed<T>> timestamp(TimeUnit unit,Scheduler scheduler)
Timed
object whose timestamps are provided by a specified Scheduler.Scheduler
.unit
- the time unit for the current timescheduler
- theScheduler
to use as a time sourcescheduler
@CheckReturnValue@SchedulerSupport(value="none")public final <R> R to(Function<? superObservable<T>,R> converter)
This allows fluent conversion to any other type.
to
does not operate by default on a particularScheduler
.R
- the resulting object typeconverter
- the function that receives the current Observable instance and returns a value@CheckReturnValue@SchedulerSupport(value="none")public final Single<List<T>> toList()
Normally, an ObservableSource that returns multiple items will do so by invoking itsObserver
'sonNext
method for each such item. You can change this behavior, instructing the ObservableSource to compose a list of all of these items and then to invoke the Observer'sonNext
function once, passing it the entire list, by calling the ObservableSource'stoList
method prior to calling itssubscribe()
method.
Note that this operator requires the upstream to signalonComplete
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
.
toList
does not operate by default on a particularScheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final Single<List<T>> toList(int capacityHint)
Normally, an ObservableSource that returns multiple items will do so by invoking itsObserver
'sonNext
method for each such item. You can change this behavior, instructing the ObservableSource to compose a list of all of these items and then to invoke the Observer'sonNext
function once, passing it the entire list, by calling the ObservableSource'stoList
method prior to calling itssubscribe()
method.
Note that this operator requires the upstream to signalonComplete
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
.
toList
does not operate by default on a particularScheduler
.capacityHint
- the number of elements expected from the current Observable@CheckReturnValue@SchedulerSupport(value="none")public final <U extendsCollection<? superT>> Single<U> toList(Callable<U> collectionSupplier)
Normally, an ObservableSource that returns multiple items will do so by invoking itsObserver
'sonNext
method for each such item. You can change this behavior, instructing the ObservableSource to compose a list of all of these items and then to invoke the Observer'sonNext
function once, passing it the entire list, by calling the ObservableSource'stoList
method prior to calling itssubscribe()
method.
Note that this operator requires the upstream to signalonComplete
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
.
toList
does not operate by default on a particularScheduler
.U
- the subclass of a collection of TscollectionSupplier
- the Callable returning the collection (for each individual Observer) to be filled in@CheckReturnValue@SchedulerSupport(value="none")public final <K> Single<Map<K,T>> toMap(Function<? superT,? extends K> keySelector)
keySelector
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 signalonComplete
for the accumulated map 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
.
toMap
does not operate by default on a particularScheduler
.K
- the key type of the MapkeySelector
- the function that extracts the key from a source item to be used in the HashMap@CheckReturnValue@SchedulerSupport(value="none")public final <K,V> Single<Map<K,V>> toMap(Function<? superT,? extends K> keySelector,Function<? superT,? extends V> valueSelector)
keySelector
function.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 signalonComplete
for the accumulated map 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
.
toMap
does not operate by default on a particularScheduler
.K
- the key type of the MapV
- the value type of the MapkeySelector
- the function that extracts the key from a source item to be used in the HashMapvalueSelector
- the function that extracts the value from a source item to be used in the HashMap@CheckReturnValue@SchedulerSupport(value="none")public final <K,V> Single<Map<K,V>> toMap(Function<? superT,? extends K> keySelector,Function<? superT,? extends V> valueSelector,Callable<? extendsMap<K,V>> mapSupplier)
mapFactory
function, that contains keys and values extracted from the items emitted by the finite source ObservableSource. Note that this operator requires the upstream to signalonComplete
for the accumulated map 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
.
toMap
does not operate by default on a particularScheduler
.K
- the key type of the MapV
- the value type of the MapkeySelector
- the function that extracts the key from a source item to be used in the MapvalueSelector
- the function that extracts the value from the source items to be used as value in the MapmapSupplier
- the function that returns a Map instance to be used@CheckReturnValue@SchedulerSupport(value="none")public final <K> Single<Map<K,Collection<T>>> toMultimap(Function<? superT,? extends K> keySelector)
keySelector
function. Note that this operator requires the upstream to signalonComplete
for the accumulated map 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
.
toMultimap
does not operate by default on a particularScheduler
.K
- the key type of the MapkeySelector
- the function that extracts the key from the source items to be used as key in the HashMap@CheckReturnValue@SchedulerSupport(value="none")public final <K,V> Single<Map<K,Collection<V>>> toMultimap(Function<? superT,? extends K> keySelector,Function<? superT,? extends V> valueSelector)
valueSelector
function from items emitted by the finite source ObservableSource, keyed by a specifiedkeySelector
function. Note that this operator requires the upstream to signalonComplete
for the accumulated map 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
.
toMultimap
does not operate by default on a particularScheduler
.K
- the key type of the MapV
- the value type of the MapkeySelector
- the function that extracts a key from the source items to be used as key in the HashMapvalueSelector
- the function that extracts a value from the source items to be used as value in the HashMap@CheckReturnValue@SchedulerSupport(value="none")public final <K,V> Single<Map<K,Collection<V>>> toMultimap(Function<? superT,? extends K> keySelector,Function<? superT,? extends V> valueSelector,Callable<? extendsMap<K,Collection<V>>> mapSupplier,Function<? super K,? extendsCollection<? super V>> collectionFactory)
mapFactory
function, that contains a custom collection of values, extracted by a specifiedvalueSelector
function from items emitted by the source ObservableSource, and keyed by thekeySelector
function.toMultimap
does not operate by default on a particularScheduler
.K
- the key type of the MapV
- the value type of the MapkeySelector
- the function that extracts a key from the source items to be used as the key in the MapvalueSelector
- the function that extracts a value from the source items to be used as the value in the MapmapSupplier
- the function that returns a Map instance to be usedcollectionFactory
- the function that returns a Collection instance for a particular key to be used in the Map@CheckReturnValue@SchedulerSupport(value="none")public final <K,V> Single<Map<K,Collection<V>>> toMultimap(Function<? superT,? extends K> keySelector,Function<? superT,? extends V> valueSelector,Callable<Map<K,Collection<V>>> mapSupplier)
mapFactory
function, that contains an ArrayList of values, extracted by a specifiedvalueSelector
function from items emitted by the finite source ObservableSource and keyed by thekeySelector
function. Note that this operator requires the upstream to signalonComplete
for the accumulated map 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
.
toMultimap
does not operate by default on a particularScheduler
.K
- the key type of the MapV
- the value type of the MapkeySelector
- the function that extracts a key from the source items to be used as the key in the MapvalueSelector
- the function that extracts a value from the source items to be used as the value in the MapmapSupplier
- the function that returns a Map instance to be used@BackpressureSupport(value=SPECIAL)@CheckReturnValue@SchedulerSupport(value="none")public final Flowable<T> toFlowable(BackpressureStrategy strategy)
Marble diagrams for the various backpressure strategies are as follows:
BackpressureStrategy.BUFFER
BackpressureStrategy.DROP
BackpressureStrategy.LATEST
BackpressureStrategy.ERROR
BackpressureStrategy.MISSING
BackpressureStrategy
enum.toFlowable
does not operate by default on a particularScheduler
.strategy
- the backpressure strategy to apply@CheckReturnValue@SchedulerSupport(value="none")public final Single<List<T>> toSortedList()
Comparable
with respect to all other items in the sequence.If any item emitted by this Observable does not implementComparable
with respect to all other items emitted by this Observable, no items will be emitted and the sequence is terminated with aClassCastException
.
Note that this operator requires the upstream to signalonComplete
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
.
toSortedList
does not operate by default on a particularScheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final Single<List<T>> toSortedList(Comparator<? superT> comparator)
Note that this operator requires the upstream to signalonComplete
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
.
toSortedList
does not operate by default on a particularScheduler
.comparator
- a function that compares two items emitted by the source ObservableSource and returns an Integer that indicates their sort order@CheckReturnValue@SchedulerSupport(value="none")public final Single<List<T>> toSortedList(Comparator<? superT> comparator, int capacityHint)
Note that this operator requires the upstream to signalonComplete
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
.
toSortedList
does not operate by default on a particularScheduler
.comparator
- a function that compares two items emitted by the source ObservableSource and returns an Integer that indicates their sort ordercapacityHint
- the initial capacity of the ArrayList used to accumulate items before sorting@CheckReturnValue@SchedulerSupport(value="none")public final Single<List<T>> toSortedList(int capacityHint)
Comparable
with respect to all other items in the sequence.If any item emitted by this Observable does not implementComparable
with respect to all other items emitted by this Observable, no items will be emitted and the sequence is terminated with aClassCastException
.
Note that this operator requires the upstream to signalonComplete
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
.
toSortedList
does not operate by default on a particularScheduler
.capacityHint
- the initial capacity of the ArrayList used to accumulate items before sorting@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<T> unsubscribeOn(Scheduler scheduler)
Scheduler
.Scheduler
this operator will use.scheduler
- theScheduler
to perform the call to dispose() of the upstream DisposableScheduler
@CheckReturnValue@SchedulerSupport(value="none")public final Observable<Observable<T>> window(long count)
count
items. When the source ObservableSource completes or encounters an error, the resulting ObservableSource emits the current window and propagates the notification from the source ObservableSource.window
does not operate by default on a particularScheduler
.count
- the maximum size of each window before it should be emittedcount
items from the source ObservableSourceIllegalArgumentException
- if either count is non-positive@CheckReturnValue@SchedulerSupport(value="none")public final Observable<Observable<T>> window(long count, long skip)
skip
items, each containing no more thancount
items. When the source ObservableSource completes or encounters an error, the resulting ObservableSource emits the current window and propagates the notification from the source ObservableSource.window
does not operate by default on a particularScheduler
.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)
.skip
items containing at mostcount
items from the source ObservableSourceIllegalArgumentException
- if either count or skip is non-positive@CheckReturnValue@SchedulerSupport(value="none")public final Observable<Observable<T>> window(long count, long skip, int bufferSize)
skip
items, each containing no more thancount
items. When the source ObservableSource completes or encounters an error, the resulting ObservableSource emits the current window and propagates the notification from the source ObservableSource.window
does not operate by default on a particularScheduler
.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 windowsskip
items containing at mostcount
items from the source ObservableSourceIllegalArgumentException
- if either count or skip is non-positive@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<Observable<T>> window(long timespan, long timeskip,TimeUnit unit)
timeskip
argument. It emits each window after a fixed timespan, specified by thetimespan
argument. When the source ObservableSource completes or ObservableSource completes or encounters an error, the resulting ObservableSource emits the current window and propagates the notification from the source ObservableSource.window
operates by default on thecomputation
Scheduler
.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@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<Observable<T>> window(long timespan, long timeskip,TimeUnit unit,Scheduler scheduler)
timeskip
argument. It emits each window after a fixed timespan, specified by thetimespan
argument. When the source ObservableSource completes or ObservableSource completes or encounters an error, the resulting ObservableSource emits the current window and propagates the notification from the source ObservableSource.Scheduler
this operator will use.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@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<Observable<T>> window(long timespan, long timeskip,TimeUnit unit,Scheduler scheduler, int bufferSize)
timeskip
argument. It emits each window after a fixed timespan, specified by thetimespan
argument. When the source ObservableSource completes or ObservableSource completes or encounters an error, the resulting ObservableSource emits the current window and propagates the notification from the source ObservableSource.Scheduler
this operator will use.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@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<Observable<T>> window(long timespan,TimeUnit unit)
timespan
argument. When the source ObservableSource completes or encounters an error, the resulting ObservableSource emits the current window and propagates the notification from the source ObservableSource.window
operates by default on thecomputation
Scheduler
.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@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<Observable<T>> window(long timespan,TimeUnit unit, long count)
timespan
argument or a maximum size as specified by thecount
argument (whichever is reached first). When the source ObservableSource completes or encounters an error, the resulting ObservableSource emits the current window and propagates the notification from the source ObservableSource.window
operates by default on thecomputation
Scheduler
.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@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Observable<Observable<T>> window(long timespan,TimeUnit unit, long count, boolean restart)
timespan
argument or a maximum size as specified by thecount
argument (whichever is reached first). When the source ObservableSource completes or encounters an error, the resulting ObservableSource emits the current window and propagates the notification from the source ObservableSource.window
operates by default on thecomputation
Scheduler
.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
- if true, when a window reaches the capacity limit, the timer is restarted as well@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<Observable<T>> window(long timespan,TimeUnit unit,Scheduler scheduler)
timespan
argument. When the source ObservableSource completes or encounters an error, the resulting ObservableSource emits the current window and propagates the notification from the source ObservableSource.Scheduler
this operator will use.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@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<Observable<T>> window(long timespan,TimeUnit unit,Scheduler scheduler, long count)
timespan
argument or a maximum size specified by thecount
argument (whichever is reached first). When the source ObservableSource completes or encounters an error, the resulting ObservableSource emits the current window and propagates the notification from the source ObservableSource.Scheduler
this operator will use.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@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<Observable<T>> window(long timespan,TimeUnit unit,Scheduler scheduler, long count, boolean restart)
timespan
argument or a maximum size specified by thecount
argument (whichever is reached first). When the source ObservableSource completes or encounters an error, the resulting ObservableSource emits the current window and propagates the notification from the source ObservableSource.Scheduler
this operator will use.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
- if true, when a window reaches the capacity limit, the timer is restarted as well@CheckReturnValue@SchedulerSupport(value="custom")public final Observable<Observable<T>> window(long timespan,TimeUnit unit,Scheduler scheduler, long count, boolean restart, int bufferSize)
timespan
argument or a maximum size specified by thecount
argument (whichever is reached first). When the source ObservableSource completes or encounters an error, the resulting ObservableSource emits the current window and propagates the notification from the source ObservableSource.Scheduler
this operator will use.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
- if true, when a window reaches the capacity limit, the timer is restarted as wellbufferSize
- the capacity hint for the buffer in the inner windows@CheckReturnValue@SchedulerSupport(value="none")public final <B> Observable<Observable<T>> window(ObservableSource<B> boundary)
window
does not operate by default on a particularScheduler
.B
- the window element type (ignored)boundary
- an ObservableSource whose emitted items close and open windowsboundary
ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final <B> Observable<Observable<T>> window(ObservableSource<B> boundary, int bufferSize)
window
does not operate by default on a particularScheduler
.B
- the window element type (ignored)boundary
- an ObservableSource whose emitted items close and open windowsbufferSize
- the capacity hint for the buffer in the inner windowsboundary
ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final <U,V> Observable<Observable<T>> window(ObservableSource<U> openingIndicator,Function<? super U,? extendsObservableSource<V>> closingIndicator)
openingIndicator
ObservableSource emits an item and when the ObservableSource returned byclosingIndicator
emits an item.window
does not operate by default on a particularScheduler
.U
- the element type of the window-opening ObservableSourceV
- the element type of the window-closing ObservableSourcesopeningIndicator
- an ObservableSource that, when it emits an item, causes another window to be createdclosingIndicator
- aFunction
that produces an ObservableSource for every window created. When this ObservableSource emits an item, the associated window is closed and emitted@CheckReturnValue@SchedulerSupport(value="none")public final <U,V> Observable<Observable<T>> window(ObservableSource<U> openingIndicator,Function<? super U,? extendsObservableSource<V>> closingIndicator, int bufferSize)
openingIndicator
ObservableSource emits an item and when the ObservableSource returned byclosingIndicator
emits an item.window
does not operate by default on a particularScheduler
.U
- the element type of the window-opening ObservableSourceV
- the element type of the window-closing ObservableSourcesopeningIndicator
- an ObservableSource that, when it emits an item, causes another window to be createdclosingIndicator
- aFunction
that produces an ObservableSource for every window created. When this ObservableSource emits an item, the associated window is closed and emittedbufferSize
- the capacity hint for the buffer in the inner windows@CheckReturnValue@SchedulerSupport(value="none")public final <B> Observable<Observable<T>> window(Callable<? extendsObservableSource<B>> boundary)
closingIndicator
emits an item.window
does not operate by default on a particularScheduler
.B
- the element type of the boundary ObservableSourceboundary
- aCallable
that returns anObservableSource
that governs the boundary between windows. When the sourceObservableSource
emits an item,window
emits the current window and begins a new one.closingIndicator
emits an item@CheckReturnValue@SchedulerSupport(value="none")public final <B> Observable<Observable<T>> window(Callable<? extendsObservableSource<B>> boundary, int bufferSize)
closingIndicator
emits an item.window
does not operate by default on a particularScheduler
.B
- the element type of the boundary ObservableSourceboundary
- aCallable
that returns anObservableSource
that governs the boundary between windows. When the sourceObservableSource
emits an item,window
emits the current window and begins a new one.bufferSize
- the capacity hint for the buffer in the inner windowsclosingIndicator
emits an item@CheckReturnValue@SchedulerSupport(value="none")public final <U,R> Observable<R> withLatestFrom(ObservableSource<? extends U> other,BiFunction<? superT,? super U,? extends R> combiner)
resultSelector
function only when the source ObservableSource (this instance) emits an item.Scheduler
.U
- the element type of the other ObservableSourceR
- the result type of the combinationother
- the other ObservableSourcecombiner
- the function to call when this ObservableSource emits an item and the other ObservableSource has already emitted an item, to generate the item to be emitted by the resulting ObservableSourceresultSelector
function only when the source ObservableSource sequence (this instance) emits an item@CheckReturnValue@SchedulerSupport(value="none")public final <T1,T2,R> Observable<R> withLatestFrom(ObservableSource<T1> o1,ObservableSource<T2> o2,Function3<? superT,? super T1,? super T2,R> combiner)
Note that this operator doesn't emit anything until all other sources have produced at least one value. The resulting emission only happens when this ObservableSource 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.
Scheduler
.T1
- the first other source's value typeT2
- the second other source's value typeR
- the result value typeo1
- the first other ObservableSourceo2
- the second other ObservableSourcecombiner
- the function called with an array of values from each participating ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final <T1,T2,T3,R> Observable<R> withLatestFrom(ObservableSource<T1> o1,ObservableSource<T2> o2,ObservableSource<T3> o3,Function4<? superT,? super T1,? super T2,? super T3,R> combiner)
Note that this operator doesn't emit anything until all other sources have produced at least one value. The resulting emission only happens when this ObservableSource 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.
Scheduler
.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 typeo1
- the first other ObservableSourceo2
- the second other ObservableSourceo3
- the third other ObservableSourcecombiner
- the function called with an array of values from each participating ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final <T1,T2,T3,T4,R> Observable<R> withLatestFrom(ObservableSource<T1> o1,ObservableSource<T2> o2,ObservableSource<T3> o3,ObservableSource<T4> o4,Function5<? superT,? super T1,? super T2,? super T3,? super T4,R> combiner)
Note that this operator doesn't emit anything until all other sources have produced at least one value. The resulting emission only happens when this ObservableSource 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.
Scheduler
.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 typeo1
- the first other ObservableSourceo2
- the second other ObservableSourceo3
- the third other ObservableSourceo4
- the fourth other ObservableSourcecombiner
- the function called with an array of values from each participating ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> withLatestFrom(ObservableSource<?>[] others,Function<? superObject[],R> combiner)
Note that this operator doesn't emit anything until all other sources have produced at least one value. The resulting emission only happens when this ObservableSource 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.
Scheduler
.R
- the result value typeothers
- the array of other sourcescombiner
- the function called with an array of values from each participating ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final <R> Observable<R> withLatestFrom(Iterable<? extendsObservableSource<?>> others,Function<? superObject[],R> combiner)
Note that this operator doesn't emit anything until all other sources have produced at least one value. The resulting emission only happens when this ObservableSource 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.
Scheduler
.R
- the result value typeothers
- the iterable of other sourcescombiner
- the function called with an array of values from each participating ObservableSource@CheckReturnValue@SchedulerSupport(value="none")public final <U,R> Observable<R> zipWith(Iterable<U> other,BiFunction<? superT,? super U,? extends R> zipper)
Note that theother
Iterable is evaluated as items are observed from the source ObservableSource; it is not pre-consumed. This allows you to zip infinite streams on either side.
zipWith
does not operate by default on a particularScheduler
.U
- the type of items in theother
IterableR
- the type of items emitted by the resulting ObservableSourceother
- the Iterable sequencezipper
- a function that combines the pairs of items from the ObservableSource and the Iterable to generate the items to be emitted by the resulting ObservableSourceother
Iterable sequence and emits the results ofzipFunction
applied to these pairs@CheckReturnValue@SchedulerSupport(value="none")public final <U,R> Observable<R> zipWith(ObservableSource<? extends U> other,BiFunction<? superT,? super U,? extends R> zipper)
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 callingdoOnComplete()
). 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.doOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.zipWith
does not operate by default on a particularScheduler
.U
- the type of items emitted by theother
ObservableSourceR
- the type of items emitted by the resulting ObservableSourceother
- the other ObservableSourcezipper
- a function that combines the pairs of items from the two ObservableSources to generate the items to be emitted by the resulting ObservableSourceother
ObservableSource and emits the results ofzipFunction
applied to these pairs@CheckReturnValue@SchedulerSupport(value="none")public final <U,R> Observable<R> zipWith(ObservableSource<? extends U> other,BiFunction<? superT,? super U,? extends R> zipper, boolean delayError)
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 callingdoOnComplete()
). 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.doOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.zipWith
does not operate by default on a particularScheduler
.U
- the type of items emitted by theother
ObservableSourceR
- the type of items emitted by the resulting ObservableSourceother
- the other ObservableSourcezipper
- a function that combines the pairs of items from the two ObservableSources to generate the items to be emitted by the resulting ObservableSourcedelayError
- if true, errors from the current Observable or the other ObservableSource is delayed until both terminateother
ObservableSource and emits the results ofzipFunction
applied to these pairs@CheckReturnValue@SchedulerSupport(value="none")public final <U,R> Observable<R> zipWith(ObservableSource<? extends U> other,BiFunction<? superT,? super U,? extends R> zipper, boolean delayError, int bufferSize)
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 callingdoOnComplete()
). 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.doOnDispose(Action)
as well or useusing()
to do cleanup in case of completion or a dispose() call.zipWith
does not operate by default on a particularScheduler
.U
- the type of items emitted by theother
ObservableSourceR
- the type of items emitted by the resulting ObservableSourceother
- the other ObservableSourcezipper
- a function that combines the pairs of items from the two ObservableSources to generate the items to be emitted by the resulting ObservableSourcebufferSize
- the capacity hint for the buffer in the inner windowsdelayError
- if true, errors from the current Observable or the other ObservableSource is delayed until both terminateother
ObservableSource and emits the results ofzipFunction
applied to these pairs@CheckReturnValue@SchedulerSupport(value="none")public final TestObserver<T> test()
test
does not operate by default on a particularScheduler
.@CheckReturnValue@SchedulerSupport(value="none")public final TestObserver<T> test(boolean dispose)
test
does not operate by default on a particularScheduler
.dispose
- dispose the TestObserver before it is subscribed to this Observable?