T
- the type of the items emitted by the Observablepublic class Observable<T>
extends java.lang.Object
This class provides methods for subscribing to the Observable as well as delegate methods to the various Observers.
The documentation for this class makes use of marble diagrams. The following legend explains these diagrams:
For more information see the ReactiveX documentation.
Modifier and Type | Class and Description |
---|---|
static interface |
Observable.OnSubscribe<T>
Invoked when Observable.subscribe is called.
|
static interface |
Observable.Operator<R,T>
Operator function for lifting into an Observable.
|
static interface |
Observable.Transformer<T,R>
Function that receives the current Observable and should return another
Observable, possibly with given element type, in exchange that will be
subscribed to by the downstream operators and subscribers.
|
Modifier | Constructor and Description |
---|---|
protected |
Observable(Observable.OnSubscribe<T> f)
Creates an Observable with a Function to execute when it is subscribed to.
|
Modifier and Type | Method and Description |
---|---|
Observable<java.lang.Boolean> |
all(Func1<? super T,java.lang.Boolean> predicate)
Returns an Observable that emits a Boolean that indicates whether all of the items emitted by the source
Observable satisfy a condition.
|
static <T> Observable<T> |
amb(java.lang.Iterable<? extends Observable<? extends T>> sources)
Mirrors the one Observable in an Iterable of several Observables that first either emits an item or sends
a termination notification.
|
static <T> Observable<T> |
amb(Observable<? extends T> o1,
Observable<? extends T> o2)
Given two Observables, mirrors the one that first either emits an item or sends a termination
notification.
|
static <T> Observable<T> |
amb(Observable<? extends T> o1,
Observable<? extends T> o2,
Observable<? extends T> o3)
Given three Observables, mirrors the one that first either emits an item or sends a termination
notification.
|
static <T> Observable<T> |
amb(Observable<? extends T> o1,
Observable<? extends T> o2,
Observable<? extends T> o3,
Observable<? extends T> o4)
Given four Observables, mirrors the one that first either emits an item or sends a termination
notification.
|
static <T> Observable<T> |
amb(Observable<? extends T> o1,
Observable<? extends T> o2,
Observable<? extends T> o3,
Observable<? extends T> o4,
Observable<? extends T> o5)
Given five Observables, mirrors the one that first either emits an item or sends a termination
notification.
|
static <T> Observable<T> |
amb(Observable<? extends T> o1,
Observable<? extends T> o2,
Observable<? extends T> o3,
Observable<? extends T> o4,
Observable<? extends T> o5,
Observable<? extends T> o6)
Given six Observables, mirrors the one that first either emits an item or sends a termination
notification.
|
static <T> Observable<T> |
amb(Observable<? extends T> o1,
Observable<? extends T> o2,
Observable<? extends T> o3,
Observable<? extends T> o4,
Observable<? extends T> o5,
Observable<? extends T> o6,
Observable<? extends T> o7)
Given seven Observables, mirrors the one that first either emits an item or sends a termination
notification.
|
static <T> Observable<T> |
amb(Observable<? extends T> o1,
Observable<? extends T> o2,
Observable<? extends T> o3,
Observable<? extends T> o4,
Observable<? extends T> o5,
Observable<? extends T> o6,
Observable<? extends T> o7,
Observable<? extends T> o8)
Given eight Observables, mirrors the one that first either emits an item or sends a termination
notification.
|
static <T> Observable<T> |
amb(Observable<? extends T> o1,
Observable<? extends T> o2,
Observable<? extends T> o3,
Observable<? extends T> o4,
Observable<? extends T> o5,
Observable<? extends T> o6,
Observable<? extends T> o7,
Observable<? extends T> o8,
Observable<? extends T> o9)
Given nine Observables, mirrors the one that first either emits an item or sends a termination
notification.
|
Observable<T> |
ambWith(Observable<? extends T> t1)
Mirrors the Observable (current or provided) that first either emits an item or sends a termination
notification.
|
Observable<T> |
asObservable()
Portrays a object of an Observable subclass as a simple Observable object.
|
<TClosing> Observable<java.util.List<T>> |
buffer(Func0<? extends Observable<? extends TClosing>> bufferClosingSelector)
Returns an Observable that emits buffers of items it collects from the source Observable.
|
Observable<java.util.List<T>> |
buffer(int count)
Returns an Observable that emits buffers of items it collects from the source Observable.
|
Observable<java.util.List<T>> |
buffer(int count,
int skip)
Returns an Observable that emits buffers of items it collects from the source Observable.
|
Observable<java.util.List<T>> |
buffer(long timespan,
long timeshift,
java.util.concurrent.TimeUnit unit)
Returns an Observable that emits buffers of items it collects from the source Observable.
|
Observable<java.util.List<T>> |
buffer(long timespan,
long timeshift,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that emits buffers of items it collects from the source Observable.
|
Observable<java.util.List<T>> |
buffer(long timespan,
java.util.concurrent.TimeUnit unit)
Returns an Observable that emits buffers of items it collects from the source Observable.
|
Observable<java.util.List<T>> |
buffer(long timespan,
java.util.concurrent.TimeUnit unit,
int count)
Returns an Observable that emits buffers of items it collects from the source Observable.
|
Observable<java.util.List<T>> |
buffer(long timespan,
java.util.concurrent.TimeUnit unit,
int count,
Scheduler scheduler)
Returns an Observable that emits buffers of items it collects from the source Observable.
|
Observable<java.util.List<T>> |
buffer(long timespan,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that emits buffers of items it collects from the source Observable.
|
<TOpening,TClosing> |
buffer(Observable<? extends TOpening> bufferOpenings,
Func1<? super TOpening,? extends Observable<? extends TClosing>> bufferClosingSelector)
Returns an Observable that emits buffers of items it collects from the source Observable.
|
<B> Observable<java.util.List<T>> |
buffer(Observable<B> boundary)
Returns an Observable that emits non-overlapping buffered items from the source Observable each time the
specified boundary Observable emits an item.
|
<B> Observable<java.util.List<T>> |
buffer(Observable<B> boundary,
int initialCapacity)
Returns an Observable that emits non-overlapping buffered items from the source Observable each time the
specified boundary Observable emits an item.
|
Observable<T> |
cache()
Returns an Observable that subscribes to this Observable lazily, caches all of its events
and replays them, in the same order as received, to all the downstream subscribers.
|
Observable<T> |
cache(int initialCapacity)
Deprecated.
Use
cacheWithInitialCapacity(int) instead. |
Observable<T> |
cacheWithInitialCapacity(int initialCapacity)
Returns an Observable that subscribes to this Observable lazily, caches all of its events
and replays them, in the same order as received, to all the downstream subscribers.
|
<R> Observable<R> |
cast(java.lang.Class<R> klass)
Returns an Observable that emits the items emitted by the source Observable, converted to the specified
type.
|
<R> Observable<R> |
collect(Func0<R> stateFactory,
Action2<R,? super T> collector)
Collects items emitted by the source Observable into a single mutable data structure and returns an
Observable that emits this structure.
|
static <T,R> Observable<R> |
combineLatest(java.lang.Iterable<? extends Observable<? extends T>> sources,
FuncN<? extends R> combineFunction)
Combines a collection of source Observables by emitting an item that aggregates the latest values of each of
the source Observables each time an item is received from any of the source Observables, where this
aggregation is defined by a specified function.
|
static <T,R> Observable<R> |
combineLatest(java.util.List<? extends Observable<? extends T>> sources,
FuncN<? extends R> combineFunction)
Combines a list of source Observables by emitting an item that aggregates the latest values of each of
the source Observables each time an item is received from any of the source Observables, where this
aggregation is defined by a specified function.
|
static <T1,T2,R> Observable<R> |
combineLatest(Observable<? extends T1> o1,
Observable<? extends T2> o2,
Func2<? super T1,? super T2,? extends R> combineFunction)
Combines two source Observables by emitting an item that aggregates the latest values of each of the
source Observables each time an item is received from either of the source Observables, where this
aggregation is defined by a specified function.
|
static <T1,T2,T3,R> |
combineLatest(Observable<? extends T1> o1,
Observable<? extends T2> o2,
Observable<? extends T3> o3,
Func3<? super T1,? super T2,? super T3,? extends R> combineFunction)
Combines three source Observables by emitting an item that aggregates the latest values of each of the
source Observables each time an item is received from any of the source Observables, where this
aggregation is defined by a specified function.
|
static <T1,T2,T3,T4,R> |
combineLatest(Observable<? extends T1> o1,
Observable<? extends T2> o2,
Observable<? extends T3> o3,
Observable<? extends T4> o4,
Func4<? super T1,? super T2,? super T3,? super T4,? extends R> combineFunction)
Combines four source Observables by emitting an item that aggregates the latest values of each of the
source Observables each time an item is received from any of the source Observables, where this
aggregation is defined by a specified function.
|
static <T1,T2,T3,T4,T5,R> |
combineLatest(Observable<? extends T1> o1,
Observable<? extends T2> o2,
Observable<? extends T3> o3,
Observable<? extends T4> o4,
Observable<? extends T5> o5,
Func5<? super T1,? super T2,? super T3,? super T4,? super T5,? extends R> combineFunction)
Combines five source Observables by emitting an item that aggregates the latest values of each of the
source Observables each time an item is received from any of the source Observables, where this
aggregation is defined by a specified function.
|
static <T1,T2,T3,T4,T5,T6,R> |
combineLatest(Observable<? extends T1> o1,
Observable<? extends T2> o2,
Observable<? extends T3> o3,
Observable<? extends T4> o4,
Observable<? extends T5> o5,
Observable<? extends T6> o6,
Func6<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? extends R> combineFunction)
Combines six source Observables by emitting an item that aggregates the latest values of each of the
source Observables each time an item is received from any of the source Observables, where this
aggregation is defined by a specified function.
|
static <T1,T2,T3,T4,T5,T6,T7,R> |
combineLatest(Observable<? extends T1> o1,
Observable<? extends T2> o2,
Observable<? extends T3> o3,
Observable<? extends T4> o4,
Observable<? extends T5> o5,
Observable<? extends T6> o6,
Observable<? extends T7> o7,
Func7<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? extends R> combineFunction)
Combines seven source Observables by emitting an item that aggregates the latest values of each of the
source Observables each time an item is received from any of the source Observables, where this
aggregation is defined by a specified function.
|
static <T1,T2,T3,T4,T5,T6,T7,T8,R> |
combineLatest(Observable<? extends T1> o1,
Observable<? extends T2> o2,
Observable<? extends T3> o3,
Observable<? extends T4> o4,
Observable<? extends T5> o5,
Observable<? extends T6> o6,
Observable<? extends T7> o7,
Observable<? extends T8> o8,
Func8<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? extends R> combineFunction)
Combines eight source Observables by emitting an item that aggregates the latest values of each of the
source Observables each time an item is received from any of the source Observables, where this
aggregation is defined by a specified function.
|
static <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> |
combineLatest(Observable<? extends T1> o1,
Observable<? extends T2> o2,
Observable<? extends T3> o3,
Observable<? extends T4> o4,
Observable<? extends T5> o5,
Observable<? extends T6> o6,
Observable<? extends T7> o7,
Observable<? extends T8> o8,
Observable<? extends T9> o9,
Func9<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? super T9,? extends R> combineFunction)
Combines nine source Observables by emitting an item that aggregates the latest values of each of the
source Observables each time an item is received from any of the source Observables, where this
aggregation is defined by a specified function.
|
static <T,R> Observable<R> |
combineLatestDelayError(java.lang.Iterable<? extends Observable<? extends T>> sources,
FuncN<? extends R> combineFunction)
Combines a collection of source Observables by emitting an item that aggregates the latest values of each of
the source Observables each time an item is received from any of the source Observables, where this
aggregation is defined by a specified function and delays any error from the sources until
all source Observables terminate.
|
<R> Observable<R> |
compose(Observable.Transformer<? super T,? extends R> transformer)
Transform an Observable by applying a particular Transformer function to it.
|
static <T> Observable<T> |
concat(java.lang.Iterable<? extends Observable<? extends T>> sequences)
Flattens an Iterable of Observables into one Observable, one after the other, without
interleaving them.
|
static <T> Observable<T> |
concat(Observable<? extends Observable<? extends T>> observables)
Returns an Observable that emits the items emitted by each of the Observables emitted by the source
Observable, one after the other, without interleaving them.
|
static <T> Observable<T> |
concat(Observable<? extends T> t1,
Observable<? extends T> t2)
Returns an Observable that emits the items emitted by two Observables, one after the other, without
interleaving them.
|
static <T> Observable<T> |
concat(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3)
Returns an Observable that emits the items emitted by three Observables, one after the other, without
interleaving them.
|
static <T> Observable<T> |
concat(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4)
Returns an Observable that emits the items emitted by four Observables, one after the other, without
interleaving them.
|
static <T> Observable<T> |
concat(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5)
Returns an Observable that emits the items emitted by five Observables, one after the other, without
interleaving them.
|
static <T> Observable<T> |
concat(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5,
Observable<? extends T> t6)
Returns an Observable that emits the items emitted by six Observables, one after the other, without
interleaving them.
|
static <T> Observable<T> |
concat(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5,
Observable<? extends T> t6,
Observable<? extends T> t7)
Returns an Observable that emits the items emitted by seven Observables, one after the other, without
interleaving them.
|
static <T> Observable<T> |
concat(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5,
Observable<? extends T> t6,
Observable<? extends T> t7,
Observable<? extends T> t8)
Returns an Observable that emits the items emitted by eight Observables, one after the other, without
interleaving them.
|
static <T> Observable<T> |
concat(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5,
Observable<? extends T> t6,
Observable<? extends T> t7,
Observable<? extends T> t8,
Observable<? extends T> t9)
Returns an Observable that emits the items emitted by nine Observables, one after the other, without
interleaving them.
|
static <T> Observable<T> |
concatDelayError(java.lang.Iterable<? extends Observable<? extends T>> sources)
Concatenates the Iterable sequence of Observables into a single sequence by subscribing to each Observable,
one after the other, one at a time and delays any errors till the all inner Observables terminate.
|
static <T> Observable<T> |
concatDelayError(Observable<? extends Observable<? extends T>> sources)
Concatenates the Observable sequence of Observables into a single sequence by subscribing to each inner Observable,
one after the other, one at a time and delays any errors till the all inner and the outer Observables terminate.
|
static <T> Observable<T> |
concatDelayError(Observable<? extends T> t1,
Observable<? extends T> t2)
Returns an Observable that emits the items emitted by two Observables, one after the other, without
interleaving them, and delays any errors till all Observables terminate.
|
static <T> Observable<T> |
concatDelayError(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3)
Returns an Observable that emits the items emitted by three Observables, one after the other, without
interleaving them, and delays any errors till all Observables terminate.
|
static <T> Observable<T> |
concatDelayError(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4)
Returns an Observable that emits the items emitted by four Observables, one after the other, without
interleaving them, and delays any errors till all Observables terminate.
|
static <T> Observable<T> |
concatDelayError(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5)
Returns an Observable that emits the items emitted by five Observables, one after the other, without
interleaving them, and delays any errors till all Observables terminate.
|
static <T> Observable<T> |
concatDelayError(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5,
Observable<? extends T> t6)
Returns an Observable that emits the items emitted by six Observables, one after the other, without
interleaving them, and delays any errors till all Observables terminate.
|
static <T> Observable<T> |
concatDelayError(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5,
Observable<? extends T> t6,
Observable<? extends T> t7)
Returns an Observable that emits the items emitted by seven Observables, one after the other, without
interleaving them, and delays any errors till all Observables terminate.
|
static <T> Observable<T> |
concatDelayError(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5,
Observable<? extends T> t6,
Observable<? extends T> t7,
Observable<? extends T> t8)
Returns an Observable that emits the items emitted by eight Observables, one after the other, without
interleaving them, and delays any errors till all Observables terminate.
|
static <T> Observable<T> |
concatDelayError(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5,
Observable<? extends T> t6,
Observable<? extends T> t7,
Observable<? extends T> t8,
Observable<? extends T> t9)
Returns an Observable that emits the items emitted by nine Observables, one after the other, without
interleaving them, and delays any errors till all Observables terminate.
|
static <T> Observable<T> |
concatEager(java.lang.Iterable<? extends Observable<? extends T>> sources)
Concatenates a sequence of Observables eagerly into a single stream of values.
|
static <T> Observable<T> |
concatEager(java.lang.Iterable<? extends Observable<? extends T>> sources,
int capacityHint)
Concatenates a sequence of Observables eagerly into a single stream of values.
|
static <T> Observable<T> |
concatEager(Observable<? extends Observable<? extends T>> sources)
Concatenates an Observable sequence of Observables eagerly into a single stream of values.
|
static <T> Observable<T> |
concatEager(Observable<? extends Observable<? extends T>> sources,
int capacityHint)
Concatenates an Observable sequence of Observables eagerly into a single stream of values.
|
static <T> Observable<T> |
concatEager(Observable<? extends T> o1,
Observable<? extends T> o2)
Concatenates two source Observables eagerly into a single stream of values.
|
static <T> Observable<T> |
concatEager(Observable<? extends T> o1,
Observable<? extends T> o2,
Observable<? extends T> o3)
Concatenates three sources eagerly into a single stream of values.
|
static <T> Observable<T> |
concatEager(Observable<? extends T> o1,
Observable<? extends T> o2,
Observable<? extends T> o3,
Observable<? extends T> o4)
Concatenates four sources eagerly into a single stream of values.
|
static <T> Observable<T> |
concatEager(Observable<? extends T> o1,
Observable<? extends T> o2,
Observable<? extends T> o3,
Observable<? extends T> o4,
Observable<? extends T> o5)
Concatenates five sources eagerly into a single stream of values.
|
static <T> Observable<T> |
concatEager(Observable<? extends T> o1,
Observable<? extends T> o2,
Observable<? extends T> o3,
Observable<? extends T> o4,
Observable<? extends T> o5,
Observable<? extends T> o6)
Concatenates six sources eagerly into a single stream of values.
|
static <T> Observable<T> |
concatEager(Observable<? extends T> o1,
Observable<? extends T> o2,
Observable<? extends T> o3,
Observable<? extends T> o4,
Observable<? extends T> o5,
Observable<? extends T> o6,
Observable<? extends T> o7)
Concatenates seven sources eagerly into a single stream of values.
|
static <T> Observable<T> |
concatEager(Observable<? extends T> o1,
Observable<? extends T> o2,
Observable<? extends T> o3,
Observable<? extends T> o4,
Observable<? extends T> o5,
Observable<? extends T> o6,
Observable<? extends T> o7,
Observable<? extends T> o8)
Concatenates eight sources eagerly into a single stream of values.
|
static <T> Observable<T> |
concatEager(Observable<? extends T> o1,
Observable<? extends T> o2,
Observable<? extends T> o3,
Observable<? extends T> o4,
Observable<? extends T> o5,
Observable<? extends T> o6,
Observable<? extends T> o7,
Observable<? extends T> o8,
Observable<? extends T> o9)
Concatenates nine sources eagerly into a single stream of values.
|
<R> Observable<R> |
concatMap(Func1<? super T,? extends Observable<? extends R>> func)
Returns a new Observable that emits items resulting from applying a function that you supply to each item
emitted by the source Observable, where that function returns an Observable, and then emitting the items
that result from concatenating those resulting Observables.
|
<R> Observable<R> |
concatMapDelayError(Func1<? super T,? extends Observable<? extends R>> func)
Maps each of the items into an Observable, 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 Observables
till all of them terminate.
|
<R> Observable<R> |
concatMapEager(Func1<? super T,? extends Observable<? extends R>> mapper)
Maps a sequence of values into Observables and concatenates these Observables eagerly into a single
Observable.
|
<R> Observable<R> |
concatMapEager(Func1<? super T,? extends Observable<? extends R>> mapper,
int capacityHint)
Maps a sequence of values into Observables and concatenates these Observables eagerly into a single
Observable.
|
<R> Observable<R> |
concatMapEager(Func1<? super T,? extends Observable<? extends R>> mapper,
int capacityHint,
int maxConcurrent)
Maps a sequence of values into Observables and concatenates these Observables eagerly into a single
Observable.
|
<R> Observable<R> |
concatMapIterable(Func1<? super T,? extends java.lang.Iterable<? extends R>> collectionSelector)
Returns an Observable that concatenate each item emitted by the source Observable with the values in an
Iterable corresponding to that item that is generated by a selector.
|
Observable<T> |
concatWith(Observable<? extends T> t1)
Returns an Observable that emits the items emitted from the current Observable, then the next, one after
the other, without interleaving them.
|
Observable<java.lang.Boolean> |
contains(java.lang.Object element)
Returns an Observable that emits a Boolean that indicates whether the source Observable emitted a
specified item.
|
Observable<java.lang.Integer> |
count()
Returns an Observable that emits the count of the total number of items emitted by the source Observable.
|
Observable<java.lang.Long> |
countLong()
Returns an Observable that counts the total number of items emitted by the source Observable and emits
this count as a 64-bit Long.
|
static <T> Observable<T> |
create(Action1<Emitter<T>> emitter,
Emitter.BackpressureMode backpressure)
Provides an API (via a cold Observable) that bridges the reactive world with the callback-style,
generally non-backpressured world.
|
static <S,T> Observable<T> |
create(AsyncOnSubscribe<S,T> asyncOnSubscribe)
Returns an Observable that respects the back-pressure semantics.
|
static <T> Observable<T> |
create(Observable.OnSubscribe<T> f)
Deprecated.
1.2.7 - inherently unsafe, use the other create() methods for basic cases or
see
unsafeCreate(OnSubscribe) for advanced cases (such as custom operators) |
static <S,T> Observable<T> |
create(SyncOnSubscribe<S,T> syncOnSubscribe)
Returns an Observable that respects the back-pressure semantics.
|
<U> Observable<T> |
debounce(Func1<? super T,? extends Observable<U>> debounceSelector)
Returns an Observable that mirrors the source Observable, except that it drops items emitted by the
source Observable that are followed by another item within a computed debounce duration.
|
Observable<T> |
debounce(long timeout,
java.util.concurrent.TimeUnit unit)
Returns an Observable that mirrors the source Observable, except that it drops items emitted by the
source Observable that are followed by newer items before a timeout value expires.
|
Observable<T> |
debounce(long timeout,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that mirrors the source Observable, except that it drops items emitted by the
source Observable that are followed by newer items before a timeout value expires on a specified
Scheduler.
|
Observable<T> |
defaultIfEmpty(T defaultValue)
Returns an Observable that emits the items emitted by the source Observable or a specified default item
if the source Observable is empty.
|
static <T> Observable<T> |
defer(Func0<Observable<T>> observableFactory)
Returns an Observable that calls an Observable factory to create an Observable for each new Observer
that subscribes.
|
<U,V> Observable<T> |
delay(Func0<? extends Observable<U>> subscriptionDelay,
Func1<? super T,? extends Observable<V>> itemDelay)
Returns an Observable that delays the subscription to and emissions from the source Observable via another
Observable on a per-item basis.
|
<U> Observable<T> |
delay(Func1<? super T,? extends Observable<U>> itemDelay)
Returns an Observable that delays the emissions of the source Observable via another Observable on a
per-item basis.
|
Observable<T> |
delay(long delay,
java.util.concurrent.TimeUnit unit)
Returns an Observable that emits the items emitted by the source Observable shifted forward in time by a
specified delay.
|
Observable<T> |
delay(long delay,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that emits the items emitted by the source Observable shifted forward in time by a
specified delay.
|
<U> Observable<T> |
delaySubscription(Func0<? extends Observable<U>> subscriptionDelay)
Returns an Observable that delays the subscription to the source Observable until a second Observable
emits an item.
|
Observable<T> |
delaySubscription(long delay,
java.util.concurrent.TimeUnit unit)
Returns an Observable that delays the subscription to the source Observable by a given amount of time.
|
Observable<T> |
delaySubscription(long delay,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that delays the subscription to the source Observable by a given amount of time,
both waiting and subscribing on a given Scheduler.
|
<U> Observable<T> |
delaySubscription(Observable<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()
Returns an Observable that reverses the effect of
materialize by transforming the
Notification objects emitted by the source Observable into the items or notifications they
represent. |
Observable<T> |
distinct()
Returns an Observable that emits all items emitted by the source Observable that are distinct.
|
<U> Observable<T> |
distinct(Func1<? super T,? extends U> keySelector)
Returns an Observable that emits all items emitted by the source Observable that are distinct according
to a key selector function.
|
Observable<T> |
distinctUntilChanged()
Returns an Observable that emits all items emitted by the source Observable that are distinct from their
immediate predecessors.
|
<U> Observable<T> |
distinctUntilChanged(Func1<? super T,? extends U> keySelector)
Returns an Observable that emits all items emitted by the source Observable that are distinct from their
immediate predecessors, according to a key selector function.
|
Observable<T> |
distinctUntilChanged(Func2<? super T,? super T,java.lang.Boolean> comparator)
Returns an Observable that emits all items emitted by the source Observable that are distinct from their
immediate predecessors when compared with each other via the provided comparator function.
|
Observable<T> |
doAfterTerminate(Action0 action)
|
Observable<T> |
doOnCompleted(Action0 onCompleted)
Modifies the source Observable so that it invokes an action when it calls
onCompleted . |
Observable<T> |
doOnEach(Action1<Notification<? super T>> onNotification)
Modifies the source Observable so that it invokes an action for each item and terminal event it emits.
|
Observable<T> |
doOnEach(Observer<? super T> observer)
Modifies the source Observable so that it notifies an Observer for each item and terminal event it emits.
|
Observable<T> |
doOnError(Action1<? super java.lang.Throwable> onError)
Modifies the source Observable so that it invokes an action if it calls
onError . |
Observable<T> |
doOnNext(Action1<? super T> onNext)
Modifies the source Observable so that it invokes an action when it calls
onNext . |
Observable<T> |
doOnRequest(Action1<? super java.lang.Long> onRequest)
Modifies the source
Observable so that it invokes the given action when it receives a
request for more items. |
Observable<T> |
doOnSubscribe(Action0 subscribe)
Modifies the source
Observable so that it invokes the given action when it is subscribed from
its subscribers. |
Observable<T> |
doOnTerminate(Action0 onTerminate)
Modifies the source Observable so that it invokes an action when it calls
onCompleted or
onError . |
Observable<T> |
doOnUnsubscribe(Action0 unsubscribe)
Calls the unsubscribe
Action0 if the downstream unsubscribes the sequence. |
Observable<T> |
elementAt(int index)
Returns an Observable that emits the single item at a specified index in a sequence of emissions from a
source Observable.
|
Observable<T> |
elementAtOrDefault(int index,
T defaultValue)
Returns an Observable that emits the item found at a specified index in a sequence of emissions from a
source Observable, or a default item if that index is out of range.
|
static <T> Observable<T> |
empty()
Returns an Observable that emits no items to the
Observer and immediately invokes its
onCompleted method. |
static <T> Observable<T> |
error(java.lang.Throwable exception)
|
Observable<java.lang.Boolean> |
exists(Func1<? super T,java.lang.Boolean> predicate)
Returns an Observable that emits
true if any item emitted by the source Observable satisfies a
specified condition, otherwise false . |
Observable<T> |
filter(Func1<? super T,java.lang.Boolean> predicate)
Filters items emitted by an Observable by only emitting those that satisfy a specified predicate.
|
Observable<T> |
finallyDo(Action0 action)
Deprecated.
use
doAfterTerminate(Action0) instead. |
Observable<T> |
first()
Returns an Observable that emits only the very first item emitted by the source Observable, or notifies
of an
NoSuchElementException if the source Observable is empty. |
Observable<T> |
first(Func1<? super T,java.lang.Boolean> predicate)
Returns an Observable that emits only the very first item emitted by the source Observable that satisfies
a specified condition, or notifies of an
NoSuchElementException if no such items are emitted. |
Observable<T> |
firstOrDefault(T defaultValue)
Returns an Observable that emits only the very first item emitted by the source Observable, or a default
item if the source Observable completes without emitting anything.
|
Observable<T> |
firstOrDefault(T defaultValue,
Func1<? super T,java.lang.Boolean> predicate)
Returns an Observable that emits only the very first item emitted by the source Observable that satisfies
a specified condition, or a default item if the source Observable emits no such items.
|
<R> Observable<R> |
flatMap(Func1<? super T,? extends Observable<? extends R>> func)
Returns an Observable that emits items based on applying a function that you supply to each item emitted
by the source Observable, where that function returns an Observable, and then merging those resulting
Observables and emitting the results of this merger.
|
<R> Observable<R> |
flatMap(Func1<? super T,? extends Observable<? extends R>> onNext,
Func1<? super java.lang.Throwable,? extends Observable<? extends R>> onError,
Func0<? extends Observable<? extends R>> onCompleted)
Returns an Observable that applies a function to each item emitted or notification raised by the source
Observable and then flattens the Observables returned from these functions and emits the resulting items.
|
<R> Observable<R> |
flatMap(Func1<? super T,? extends Observable<? extends R>> onNext,
Func1<? super java.lang.Throwable,? extends Observable<? extends R>> onError,
Func0<? extends Observable<? extends R>> onCompleted,
int maxConcurrent)
Returns an Observable that applies a function to each item emitted or notification raised by the source
Observable and then flattens the Observables returned from these functions and emits the resulting items,
while limiting the maximum number of concurrent subscriptions to these Observables.
|
<R> Observable<R> |
flatMap(Func1<? super T,? extends Observable<? extends R>> func,
int maxConcurrent)
Returns an Observable that emits items based on applying a function that you supply to each item emitted
by the source Observable, where that function returns an Observable, and then merging those resulting
Observables and emitting the results of this merger, while limiting the maximum number of concurrent
subscriptions to these Observables.
|
<U,R> Observable<R> |
flatMap(Func1<? super T,? extends Observable<? extends U>> collectionSelector,
Func2<? super T,? 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 Observable and a specified collection Observable.
|
<U,R> Observable<R> |
flatMap(Func1<? super T,? extends Observable<? extends U>> collectionSelector,
Func2<? super T,? super U,? extends R> resultSelector,
int maxConcurrent)
Returns an Observable that emits the results of a specified function to the pair of values emitted by the
source Observable and a specified collection Observable, while limiting the maximum number of concurrent
subscriptions to these Observables.
|
Observable<T> |
flatMapCompletable(Func1<? super T,? extends Completable> mapper)
Maps all upstream values to Completables and runs them together until the upstream
and all inner Completables complete normally.
|
Observable<T> |
flatMapCompletable(Func1<? super T,? extends Completable> mapper,
boolean delayErrors)
Maps all upstream values to Completables and runs them together, optionally delaying any errors, until the upstream
and all inner Completables terminate.
|
Observable<T> |
flatMapCompletable(Func1<? super T,? extends Completable> mapper,
boolean delayErrors,
int maxConcurrency)
Maps upstream values to Completables and runs up to the given number of them together at a time,
optionally delaying any errors, until the upstream and all inner Completables terminate.
|
<R> Observable<R> |
flatMapIterable(Func1<? super T,? extends java.lang.Iterable<? extends R>> collectionSelector)
Returns an Observable that merges each item emitted by the source Observable with the values in an
Iterable corresponding to that item that is generated by a selector.
|
<R> Observable<R> |
flatMapIterable(Func1<? super T,? extends java.lang.Iterable<? extends R>> collectionSelector,
int maxConcurrent)
Returns an Observable that merges each item emitted by the source Observable with the values in an
Iterable corresponding to that item that is generated by a selector, while limiting the number of concurrent
subscriptions to these Observables.
|
<U,R> Observable<R> |
flatMapIterable(Func1<? super T,? extends java.lang.Iterable<? extends U>> collectionSelector,
Func2<? super T,? super U,? extends R> resultSelector)
Returns an Observable that emits the results of applying a function to the pair of values from the source
Observable and an Iterable corresponding to that item that is generated by a selector.
|
<U,R> Observable<R> |
flatMapIterable(Func1<? super T,? extends java.lang.Iterable<? extends U>> collectionSelector,
Func2<? super T,? super U,? extends R> resultSelector,
int maxConcurrent)
Returns an Observable that emits the results of applying a function to the pair of values from the source
Observable and an Iterable corresponding to that item that is generated by a selector, while limiting the
number of concurrent subscriptions to these Observables.
|
<R> Observable<R> |
flatMapSingle(Func1<? super T,? extends Single<? extends R>> mapper)
Maps all upstream values to Singles and runs them together until the upstream
and all inner Singles complete normally.
|
<R> Observable<R> |
flatMapSingle(Func1<? super T,? extends Single<? extends R>> mapper,
boolean delayErrors)
Maps all upstream values to Singles and runs them together, optionally delaying any errors, until the upstream
and all inner Singles terminate.
|
<R> Observable<R> |
flatMapSingle(Func1<? super T,? extends Single<? extends R>> mapper,
boolean delayErrors,
int maxConcurrency)
Maps upstream values to Singles and runs up to the given number of them together at a time,
optionally delaying any errors, until the upstream and all inner Singles terminate.
|
void |
forEach(Action1<? super T> onNext)
Subscribes to the
Observable and receives notifications for each element. |
void |
forEach(Action1<? super T> onNext,
Action1<java.lang.Throwable> onError)
Subscribes to the
Observable and receives notifications for each element and error events. |
void |
forEach(Action1<? super T> onNext,
Action1<java.lang.Throwable> onError,
Action0 onComplete)
Subscribes to the
Observable and receives notifications for each element and the terminal events. |
static <T> Observable<T> |
from(java.util.concurrent.Future<? extends T> future)
Converts a
Future into an Observable. |
static <T> Observable<T> |
from(java.util.concurrent.Future<? extends T> future,
long timeout,
java.util.concurrent.TimeUnit unit)
Converts a
Future into an Observable, with a timeout on the Future. |
static <T> Observable<T> |
from(java.util.concurrent.Future<? extends T> future,
Scheduler scheduler)
Converts a
Future , operating on a specified Scheduler , into an Observable. |
static <T> Observable<T> |
from(java.lang.Iterable<? extends T> iterable)
Converts an
Iterable sequence into an Observable that emits the items in the sequence. |
static <T> Observable<T> |
from(T[] array)
Converts an Array into an Observable that emits the items in the Array.
|
static <T> Observable<T> |
fromCallable(java.util.concurrent.Callable<? extends T> func)
Returns an Observable that, when an observer subscribes to it, invokes a function you specify and then
emits the value returned from that function.
|
<K> Observable<GroupedObservable<K,T>> |
groupBy(Func1<? super T,? extends K> keySelector)
Groups the items emitted by an
Observable according to a specified criterion, and emits these
grouped items as GroupedObservable s. |
<K,R> Observable<GroupedObservable<K,R>> |
groupBy(Func1<? super T,? extends K> keySelector,
Func1<? super T,? extends R> elementSelector)
Groups the items emitted by an
Observable according to a specified criterion, and emits these
grouped items as GroupedObservable s. |
<K,R> Observable<GroupedObservable<K,R>> |
groupBy(Func1<? super T,? extends K> keySelector,
Func1<? super T,? extends R> elementSelector,
Func1<Action1<K>,java.util.Map<K,java.lang.Object>> evictingMapFactory)
Deprecated.
since 1.3.7, use
groupBy(Func1, Func1, int, boolean, Func1)
instead which uses much less memory. Please take note of the
usage difference involving the evicting action which now expects
the value from the map instead of the key. |
<K,R> Observable<GroupedObservable<K,R>> |
groupBy(Func1<? super T,? extends K> keySelector,
Func1<? super T,? extends R> elementSelector,
int bufferSize,
boolean delayError,
Func1<Action1<java.lang.Object>,java.util.Map<K,java.lang.Object>> evictingMapFactory)
Groups the items emitted by an
Observable according to a specified criterion, and emits these
grouped items as GroupedObservable s. |
<T2,D1,D2,R> |
groupJoin(Observable<T2> right,
Func1<? super T,? extends Observable<D1>> leftDuration,
Func1<? super T2,? extends Observable<D2>> rightDuration,
Func2<? super T,? super Observable<T2>,? extends R> resultSelector)
Returns an Observable that correlates two Observables when they overlap in time and groups the results.
|
Observable<T> |
ignoreElements()
Ignores all items emitted by the source Observable and only calls
onCompleted or onError . |
static Observable<java.lang.Long> |
interval(long initialDelay,
long period,
java.util.concurrent.TimeUnit unit)
Returns an Observable that emits a
0L after the initialDelay and ever increasing numbers
after each period of time thereafter. |
static Observable<java.lang.Long> |
interval(long initialDelay,
long period,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that emits a
0L after the initialDelay and ever increasing numbers
after each period of time thereafter, on a specified Scheduler . |
static Observable<java.lang.Long> |
interval(long interval,
java.util.concurrent.TimeUnit unit)
Returns an Observable that emits a sequential number every specified interval of time.
|
static Observable<java.lang.Long> |
interval(long interval,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that emits a sequential number every specified interval of time, on a
specified Scheduler.
|
Observable<java.lang.Boolean> |
isEmpty()
Returns an Observable that emits
true if the source Observable is empty, otherwise false . |
<TRight,TLeftDuration,TRightDuration,R> |
join(Observable<TRight> right,
Func1<T,Observable<TLeftDuration>> leftDurationSelector,
Func1<TRight,Observable<TRightDuration>> rightDurationSelector,
Func2<T,TRight,R> resultSelector)
Correlates the items emitted by two Observables based on overlapping durations.
|
static <T> Observable<T> |
just(T value)
Returns an Observable that emits a single item and then completes.
|
static <T> Observable<T> |
just(T t1,
T t2)
Converts two items into an Observable that emits those items.
|
static <T> Observable<T> |
just(T t1,
T t2,
T t3)
Converts three items into an Observable that emits those items.
|
static <T> Observable<T> |
just(T t1,
T t2,
T t3,
T t4)
Converts four items into an Observable that emits those items.
|
static <T> Observable<T> |
just(T t1,
T t2,
T t3,
T t4,
T t5)
Converts five items into an Observable that emits those items.
|
static <T> Observable<T> |
just(T t1,
T t2,
T t3,
T t4,
T t5,
T t6)
Converts six items into an Observable that emits those items.
|
static <T> Observable<T> |
just(T t1,
T t2,
T t3,
T t4,
T t5,
T t6,
T t7)
Converts seven items into an Observable that emits those items.
|
static <T> Observable<T> |
just(T t1,
T t2,
T t3,
T t4,
T t5,
T t6,
T t7,
T t8)
Converts eight items into an Observable that emits those items.
|
static <T> Observable<T> |
just(T t1,
T t2,
T t3,
T t4,
T t5,
T t6,
T t7,
T t8,
T t9)
Converts nine items into an Observable that emits those items.
|
static <T> Observable<T> |
just(T t1,
T t2,
T t3,
T t4,
T t5,
T t6,
T t7,
T t8,
T t9,
T t10)
Converts ten items into an Observable that emits those items.
|
Observable<T> |
last()
Returns an Observable that emits the last item emitted by the source Observable or notifies observers of
a
NoSuchElementException if the source Observable is empty. |
Observable<T> |
last(Func1<? super T,java.lang.Boolean> predicate)
Returns an Observable that emits only the last item emitted by the source Observable that satisfies a
given condition, or notifies of a
NoSuchElementException if no such items are emitted. |
Observable<T> |
lastOrDefault(T defaultValue)
Returns an Observable that emits only the last item emitted by the source Observable, or a default item
if the source Observable completes without emitting any items.
|
Observable<T> |
lastOrDefault(T defaultValue,
Func1<? super T,java.lang.Boolean> predicate)
Returns an Observable that emits only the last item emitted by the source Observable that satisfies a
specified condition, or a default item if no such item is emitted by the source Observable.
|
<R> Observable<R> |
lift(Observable.Operator<? extends R,? super T> operator)
This method requires advanced knowledge about building operators; please consider
other standard composition methods first;
Lifts a function to the current Observable and returns a new Observable that when subscribed to will pass
the values of the current Observable through the Operator function.
|
Observable<T> |
limit(int count)
Returns an Observable that emits only the first
count items emitted by the source Observable. |
<R> Observable<R> |
map(Func1<? super T,? extends R> func)
Returns an Observable that applies a specified function to each item emitted by the source Observable and
emits the results of these function applications.
|
Observable<Notification<T>> |
materialize()
Returns an Observable that represents all of the emissions and notifications from the source
Observable into emissions marked with their original types within
Notification objects. |
static <T> Observable<T> |
merge(java.lang.Iterable<? extends Observable<? extends T>> sequences)
Flattens an Iterable of Observables into one Observable, without any transformation.
|
static <T> Observable<T> |
merge(java.lang.Iterable<? extends Observable<? extends T>> sequences,
int maxConcurrent)
Flattens an Iterable of Observables into one Observable, without any transformation, while limiting the
number of concurrent subscriptions to these Observables.
|
static <T> Observable<T> |
merge(Observable<? extends Observable<? extends T>> source)
Flattens an Observable that emits Observables into a single Observable that emits the items emitted by
those Observables, without any transformation.
|
static <T> Observable<T> |
merge(Observable<? extends Observable<? extends T>> source,
int maxConcurrent)
Flattens an Observable that emits Observables into a single Observable that emits the items emitted by
those Observables, without any transformation, while limiting the maximum number of concurrent
subscriptions to these Observables.
|
static <T> Observable<T> |
merge(Observable<? extends T>[] sequences)
Flattens an Array of Observables into one Observable, without any transformation.
|
static <T> Observable<T> |
merge(Observable<? extends T>[] sequences,
int maxConcurrent)
Flattens an Array of Observables into one Observable, without any transformation, while limiting the
number of concurrent subscriptions to these Observables.
|
static <T> Observable<T> |
merge(Observable<? extends T> t1,
Observable<? extends T> t2)
Flattens two Observables into a single Observable, without any transformation.
|
static <T> Observable<T> |
merge(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3)
Flattens three Observables into a single Observable, without any transformation.
|
static <T> Observable<T> |
merge(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4)
Flattens four Observables into a single Observable, without any transformation.
|
static <T> Observable<T> |
merge(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5)
Flattens five Observables into a single Observable, without any transformation.
|
static <T> Observable<T> |
merge(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5,
Observable<? extends T> t6)
Flattens six Observables into a single Observable, without any transformation.
|
static <T> Observable<T> |
merge(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5,
Observable<? extends T> t6,
Observable<? extends T> t7)
Flattens seven Observables into a single Observable, without any transformation.
|
static <T> Observable<T> |
merge(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5,
Observable<? extends T> t6,
Observable<? extends T> t7,
Observable<? extends T> t8)
Flattens eight Observables into a single Observable, without any transformation.
|
static <T> Observable<T> |
merge(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5,
Observable<? extends T> t6,
Observable<? extends T> t7,
Observable<? extends T> t8,
Observable<? extends T> t9)
Flattens nine Observables into a single Observable, without any transformation.
|
static <T> Observable<T> |
mergeDelayError(java.lang.Iterable<? extends Observable<? extends T>> sequences)
Flattens an Iterable of Observables into one Observable, in a way that allows an Observer to receive all
successfully emitted items from each of the source Observables without being interrupted by an error
notification from one of them.
|
static <T> Observable<T> |
mergeDelayError(java.lang.Iterable<? extends Observable<? extends T>> sequences,
int maxConcurrent)
Flattens an Iterable of Observables into one Observable, in a way that allows an Observer to receive all
successfully emitted items from each of the source Observables without being interrupted by an error
notification from one of them, while limiting the number of concurrent subscriptions to these Observables.
|
static <T> Observable<T> |
mergeDelayError(Observable<? extends Observable<? extends T>> source)
Flattens an Observable that emits Observables into one Observable, in a way that allows an Observer to
receive all successfully emitted items from all of the source Observables without being interrupted by
an error notification from one of them.
|
static <T> Observable<T> |
mergeDelayError(Observable<? extends Observable<? extends T>> source,
int maxConcurrent)
Flattens an Observable that emits Observables into one Observable, in a way that allows an Observer to
receive all successfully emitted items from all of the source Observables without being interrupted by
an error notification from one of them, while limiting the
number of concurrent subscriptions to these Observables.
|
static <T> Observable<T> |
mergeDelayError(Observable<? extends T> t1,
Observable<? extends T> t2)
Flattens two Observables into one Observable, in a way that allows an Observer to receive all
successfully emitted items from each of the source Observables without being interrupted by an error
notification from one of them.
|
static <T> Observable<T> |
mergeDelayError(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3)
Flattens three Observables into one Observable, in a way that allows an Observer to receive all
successfully emitted items from all of the source Observables without being interrupted by an error
notification from one of them.
|
static <T> Observable<T> |
mergeDelayError(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4)
Flattens four Observables into one Observable, in a way that allows an Observer to receive all
successfully emitted items from all of the source Observables without being interrupted by an error
notification from one of them.
|
static <T> Observable<T> |
mergeDelayError(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5)
Flattens five Observables into one Observable, in a way that allows an Observer to receive all
successfully emitted items from all of the source Observables without being interrupted by an error
notification from one of them.
|
static <T> Observable<T> |
mergeDelayError(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5,
Observable<? extends T> t6)
Flattens six Observables into one Observable, in a way that allows an Observer to receive all
successfully emitted items from all of the source Observables without being interrupted by an error
notification from one of them.
|
static <T> Observable<T> |
mergeDelayError(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5,
Observable<? extends T> t6,
Observable<? extends T> t7)
Flattens seven Observables into one Observable, in a way that allows an Observer to receive all
successfully emitted items from all of the source Observables without being interrupted by an error
notification from one of them.
|
static <T> Observable<T> |
mergeDelayError(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5,
Observable<? extends T> t6,
Observable<? extends T> t7,
Observable<? extends T> t8)
Flattens eight Observables into one Observable, in a way that allows an Observer to receive all
successfully emitted items from all of the source Observables without being interrupted by an error
notification from one of them.
|
static <T> Observable<T> |
mergeDelayError(Observable<? extends T> t1,
Observable<? extends T> t2,
Observable<? extends T> t3,
Observable<? extends T> t4,
Observable<? extends T> t5,
Observable<? extends T> t6,
Observable<? extends T> t7,
Observable<? extends T> t8,
Observable<? extends T> t9)
Flattens nine Observables into one Observable, in a way that allows an Observer to receive all
successfully emitted items from all of the source Observables without being interrupted by an error
notification from one of them.
|
Observable<T> |
mergeWith(Observable<? extends T> t1)
Flattens this and another Observable into a single Observable, without any transformation.
|
Observable<Observable<T>> |
nest()
Converts the source
Observable<T> into an Observable<Observable<T>> that emits the
source Observable as its single emission. |
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 Observable to perform its emissions and notifications on a specified
Scheduler ,
asynchronously with a bounded buffer of RxRingBuffer.SIZE slots. |
Observable<T> |
observeOn(Scheduler scheduler,
boolean delayError)
Modifies an Observable to perform its emissions and notifications on a specified
Scheduler ,
asynchronously with a bounded buffer and optionally delays onError notifications. |
Observable<T> |
observeOn(Scheduler scheduler,
boolean delayError,
int bufferSize)
Modifies an Observable to perform its emissions and notifications on a specified
Scheduler ,
asynchronously with a bounded buffer of configurable size and optionally delays onError notifications. |
Observable<T> |
observeOn(Scheduler scheduler,
int bufferSize)
Modifies an Observable to perform its emissions and notifications on a specified
Scheduler ,
asynchronously with a bounded buffer of configurable size. |
<R> Observable<R> |
ofType(java.lang.Class<R> klass)
Filters the items emitted by an Observable, only emitting those of the specified type.
|
Observable<T> |
onBackpressureBuffer()
Instructs an Observable that is emitting items faster than its observer can consume them to buffer these
items indefinitely until they can be emitted.
|
Observable<T> |
onBackpressureBuffer(long capacity)
Instructs an Observable that is emitting items faster than its observer can consume them to buffer up to
a given amount of items until they can be emitted.
|
Observable<T> |
onBackpressureBuffer(long capacity,
Action0 onOverflow)
Instructs an Observable that is emitting items faster than its observer can consume them to buffer up to
a given amount of items until they can be emitted.
|
Observable<T> |
onBackpressureBuffer(long capacity,
Action0 onOverflow,
BackpressureOverflow.Strategy overflowStrategy)
Instructs an Observable that is emitting items faster than its observer can consume them to buffer up to
a given amount of items until they can be emitted.
|
Observable<T> |
onBackpressureDrop()
Instructs an Observable that is emitting items faster than its observer can consume them to discard,
rather than emit, those items that its observer is not prepared to observe.
|
Observable<T> |
onBackpressureDrop(Action1<? super T> onDrop)
Instructs an Observable that is emitting items faster than its observer can consume them to discard,
rather than emit, those items that its observer is not prepared to observe.
|
Observable<T> |
onBackpressureLatest()
Instructs an Observable that is emitting items faster than its observer can consume them to
hold onto the latest value and emit that on request.
|
Observable<T> |
onErrorResumeNext(Func1<? super java.lang.Throwable,? extends Observable<? extends T>> resumeFunction)
Instructs an Observable to pass control to another Observable rather than invoking
onError if it encounters an error. |
Observable<T> |
onErrorResumeNext(Observable<? extends T> resumeSequence)
Instructs an Observable to pass control to another Observable rather than invoking
onError if it encounters an error. |
Observable<T> |
onErrorReturn(Func1<? super java.lang.Throwable,? extends T> resumeFunction)
Instructs an Observable to emit an item (returned by a specified function) rather than invoking
onError if it encounters an error. |
Observable<T> |
onExceptionResumeNext(Observable<? extends T> resumeSequence)
Instructs an Observable to pass control to another Observable rather than invoking
onError if it encounters an Exception . |
Observable<T> |
onTerminateDetach()
Nulls out references to the upstream producer and downstream Subscriber if
the sequence is terminated or downstream unsubscribes.
|
ConnectableObservable<T> |
publish()
Returns a
ConnectableObservable , which is a variety of Observable that waits until its
connect method is called before it begins emitting items to those
Observer s that have subscribed to it. |
<R> Observable<R> |
publish(Func1<? super Observable<T>,? extends Observable<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. |
static Observable<java.lang.Integer> |
range(int start,
int count)
Returns an Observable that emits a sequence of Integers within a specified range.
|
static Observable<java.lang.Integer> |
range(int start,
int count,
Scheduler scheduler)
Returns an Observable that emits a sequence of Integers within a specified range, on a specified
Scheduler.
|
Observable<T> |
rebatchRequests(int n)
Requests
n initially from the upstream and then 75% of n subsequently
after 75% of n values have been emitted to the downstream. |
Observable<T> |
reduce(Func2<T,T,T> accumulator)
Returns an Observable that applies a specified accumulator function to the first item emitted by a source
Observable, then feeds the result of that function along with the second item emitted by the source
Observable into the same function, and so on until all items have been emitted by the source Observable,
and emits the final result from the final call to your function as its sole item.
|
<R> Observable<R> |
reduce(R initialValue,
Func2<R,? super T,R> accumulator)
Returns an Observable that applies a specified accumulator function to the first item emitted by a source
Observable and a specified seed value, then feeds the result of that function along with the second item
emitted by an Observable into the same function, and so on until all items have been emitted by the
source Observable, 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 Observable indefinitely.
|
Observable<T> |
repeat(long count)
Returns an Observable that repeats the sequence of items emitted by the source Observable at most
count times. |
Observable<T> |
repeat(long count,
Scheduler scheduler)
Returns an Observable that repeats the sequence of items emitted by the source Observable at most
count times, on a particular Scheduler. |
Observable<T> |
repeat(Scheduler scheduler)
Returns an Observable that repeats the sequence of items emitted by the source Observable indefinitely,
on a particular Scheduler.
|
Observable<T> |
repeatWhen(Func1<? super Observable<? extends java.lang.Void>,? extends Observable<?>> notificationHandler)
Returns an Observable that emits the same values as the source Observable with the exception of an
onCompleted . |
Observable<T> |
repeatWhen(Func1<? super Observable<? extends java.lang.Void>,? extends Observable<?>> notificationHandler,
Scheduler scheduler)
Returns an Observable that emits the same values as the source Observable with the exception of an
onCompleted . |
ConnectableObservable<T> |
replay()
Returns a
ConnectableObservable that shares a single subscription to the underlying Observable
that will replay all of its items and notifications to any future Observer . |
<R> Observable<R> |
replay(Func1<? super Observable<T>,? extends Observable<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 Observable. |
<R> Observable<R> |
replay(Func1<? super Observable<T>,? extends Observable<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 Observable,
replaying bufferSize notifications. |
<R> Observable<R> |
replay(Func1<? super Observable<T>,? extends Observable<R>> selector,
int bufferSize,
long time,
java.util.concurrent.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 Observable,
replaying no more than bufferSize items that were emitted within a specified time window. |
<R> Observable<R> |
replay(Func1<? super Observable<T>,? extends Observable<R>> selector,
int bufferSize,
long time,
java.util.concurrent.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 Observable,
replaying no more than bufferSize items that were emitted within a specified time window. |
<R> Observable<R> |
replay(Func1<? super Observable<T>,? extends Observable<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 Observable,
replaying a maximum of bufferSize items. |
<R> Observable<R> |
replay(Func1<? super Observable<T>,? extends Observable<R>> selector,
long time,
java.util.concurrent.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 Observable,
replaying all items that were emitted within a specified time window. |
<R> Observable<R> |
replay(Func1<? super Observable<T>,? extends Observable<R>> selector,
long time,
java.util.concurrent.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 Observable,
replaying all items that were emitted within a specified time window. |
<R> Observable<R> |
replay(Func1<? super Observable<T>,? extends Observable<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 Observable. |
ConnectableObservable<T> |
replay(int bufferSize)
Returns a
ConnectableObservable that shares a single subscription to the source Observable that
replays at most bufferSize items emitted by that Observable. |
ConnectableObservable<T> |
replay(int bufferSize,
long time,
java.util.concurrent.TimeUnit unit)
Returns a
ConnectableObservable that shares a single subscription to the source Observable and
replays at most bufferSize items that were emitted during a specified time window. |
ConnectableObservable<T> |
replay(int bufferSize,
long time,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns a
ConnectableObservable that shares a single subscription to the source Observable and
that replays a maximum of bufferSize 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 Observable and
replays at most bufferSize items emitted by that Observable. |
ConnectableObservable<T> |
replay(long time,
java.util.concurrent.TimeUnit unit)
Returns a
ConnectableObservable that shares a single subscription to the source Observable and
replays all items emitted by that Observable within a specified time window. |
ConnectableObservable<T> |
replay(long time,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns a
ConnectableObservable that shares a single subscription to the source Observable and
replays all items emitted by that Observable within a specified time window. |
ConnectableObservable<T> |
replay(Scheduler scheduler)
Returns a
ConnectableObservable that shares a single subscription to the source Observable that
will replay all of its items and notifications to any future Observer on the given
Scheduler . |
Observable<T> |
retry()
Returns an Observable that mirrors the source Observable, resubscribing to it if it calls
onError
(infinite retry count). |
Observable<T> |
retry(Func2<java.lang.Integer,java.lang.Throwable,java.lang.Boolean> predicate)
Returns an Observable that mirrors the source Observable, resubscribing to it if it calls
onError
and the predicate returns true for that specific exception and retry count. |
Observable<T> |
retry(long count)
Returns an Observable that mirrors the source Observable, resubscribing to it if it calls
onError
up to a specified number of retries. |
Observable<T> |
retryWhen(Func1<? super Observable<? extends java.lang.Throwable>,? extends Observable<?>> notificationHandler)
Returns an Observable that emits the same values as the source observable with the exception of an
onError . |
Observable<T> |
retryWhen(Func1<? super Observable<? extends java.lang.Throwable>,? extends Observable<?>> notificationHandler,
Scheduler scheduler)
Returns an Observable that emits the same values as the source observable with the exception of an
onError . |
Observable<T> |
sample(long period,
java.util.concurrent.TimeUnit unit)
Returns an Observable that emits the most recently emitted item (if any) emitted by the source Observable
within periodic time intervals.
|
Observable<T> |
sample(long period,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that emits the most recently emitted item (if any) emitted by the source Observable
within periodic time intervals, where the intervals are defined on a particular Scheduler.
|
<U> Observable<T> |
sample(Observable<U> sampler)
Returns an Observable that, when the specified
sampler Observable emits an item or completes,
emits the most recently emitted item (if any) emitted by the source Observable since the previous
emission from the sampler Observable. |
Observable<T> |
scan(Func2<T,T,T> accumulator)
Returns an Observable that applies a specified accumulator function to the first item emitted by a source
Observable, then feeds the result of that function along with the second item emitted by the source
Observable into the same function, and so on until all items have been emitted by the source Observable,
emitting the result of each of these iterations.
|
<R> Observable<R> |
scan(R initialValue,
Func2<R,? super T,R> accumulator)
Returns an Observable that applies a specified accumulator function to the first item emitted by a source
Observable and a seed value, then feeds the result of that function along with the second item emitted by
the source Observable into the same function, and so on until all items have been emitted by the source
Observable, emitting the result of each of these iterations.
|
static <T> Observable<java.lang.Boolean> |
sequenceEqual(Observable<? extends T> first,
Observable<? extends T> second)
Returns an Observable that emits a Boolean value that indicates whether two Observable sequences are the
same by comparing the items emitted by each Observable pairwise.
|
static <T> Observable<java.lang.Boolean> |
sequenceEqual(Observable<? extends T> first,
Observable<? extends T> second,
Func2<? super T,? super T,java.lang.Boolean> equality)
Returns an Observable that emits a Boolean value that indicates whether two Observable sequences are the
same by comparing the items emitted by each Observable pairwise based on the results of a specified
equality function.
|
Observable<T> |
serialize()
Forces an Observable's emissions and notifications to be serialized and for it to obey
the Observable contract in other ways.
|
Observable<T> |
share()
Returns a new
Observable that multicasts (shares) the original Observable . |
Observable<T> |
single()
Returns an Observable that emits the single item emitted by the source Observable, if that Observable
emits only a single item.
|
Observable<T> |
single(Func1<? super T,java.lang.Boolean> predicate)
Returns an Observable that emits the single item emitted by the source Observable that matches a
specified predicate, if that Observable emits one such item.
|
Observable<T> |
singleOrDefault(T defaultValue)
Returns an Observable that emits the single item emitted by the source Observable, if that Observable
emits only a single item, or a default item if the source Observable emits no items.
|
Observable<T> |
singleOrDefault(T defaultValue,
Func1<? super T,java.lang.Boolean> predicate)
Returns an Observable that emits the single item emitted by the source Observable that matches a
predicate, if that Observable emits only one such item, or a default item if the source Observable emits
no such items.
|
Observable<T> |
skip(int count)
Returns an Observable that skips the first
count items emitted by the source Observable and emits
the remainder. |
Observable<T> |
skip(long time,
java.util.concurrent.TimeUnit unit)
Returns an Observable that skips values emitted by the source Observable before a specified time window
elapses.
|
Observable<T> |
skip(long time,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that skips values emitted by the source Observable 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 Observable.
|
Observable<T> |
skipLast(long time,
java.util.concurrent.TimeUnit unit)
Returns an Observable that drops items emitted by the source Observable during a specified time window
before the source completes.
|
Observable<T> |
skipLast(long time,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that drops items emitted by the source Observable during a specified time window
(defined on a specified scheduler) before the source completes.
|
<U> Observable<T> |
skipUntil(Observable<U> other)
Returns an Observable that skips items emitted by the source Observable until a second Observable emits
an item.
|
Observable<T> |
skipWhile(Func1<? super T,java.lang.Boolean> predicate)
Returns an Observable that skips all items emitted by the source Observable 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 Observable, in a
sorted order.
|
Observable<T> |
sorted(Func2<? super T,? super T,java.lang.Integer> sortFunction)
Returns an Observable that emits the events emitted by source Observable, in a
sorted order based on a specified comparison function.
|
Observable<T> |
startWith(java.lang.Iterable<T> values)
Returns an Observable that emits the items in a specified
Iterable before it begins to emit items
emitted by the source Observable. |
Observable<T> |
startWith(Observable<T> values)
Returns an Observable that emits the items in a specified
Observable before it begins to emit
items emitted by the source Observable. |
Observable<T> |
startWith(T t1)
Returns an Observable that emits a specified item before it begins to emit items emitted by the source
Observable.
|
Observable<T> |
startWith(T t1,
T t2)
Returns an Observable that emits the specified items before it begins to emit items emitted by the source
Observable.
|
Observable<T> |
startWith(T t1,
T t2,
T t3)
Returns an Observable that emits the specified items before it begins to emit items emitted by the source
Observable.
|
Observable<T> |
startWith(T t1,
T t2,
T t3,
T t4)
Returns an Observable that emits the specified items before it begins to emit items emitted by the source
Observable.
|
Observable<T> |
startWith(T t1,
T t2,
T t3,
T t4,
T t5)
Returns an Observable that emits the specified items before it begins to emit items emitted by the source
Observable.
|
Observable<T> |
startWith(T t1,
T t2,
T t3,
T t4,
T t5,
T t6)
Returns an Observable that emits the specified items before it begins to emit items emitted by the source
Observable.
|
Observable<T> |
startWith(T t1,
T t2,
T t3,
T t4,
T t5,
T t6,
T t7)
Returns an Observable that emits the specified items before it begins to emit items emitted by the source
Observable.
|
Observable<T> |
startWith(T t1,
T t2,
T t3,
T t4,
T t5,
T t6,
T t7,
T t8)
Returns an Observable that emits the specified items before it begins to emit items emitted by the source
Observable.
|
Observable<T> |
startWith(T t1,
T t2,
T t3,
T t4,
T t5,
T t6,
T t7,
T t8,
T t9)
Returns an Observable that emits the specified items before it begins to emit items emitted by the source
Observable.
|
Subscription |
subscribe()
Subscribes to an Observable and ignores
onNext and onCompleted emissions. |
Subscription |
subscribe(Action1<? super T> onNext)
Subscribes to an Observable and provides a callback to handle the items it emits.
|
Subscription |
subscribe(Action1<? super T> onNext,
Action1<java.lang.Throwable> onError)
Subscribes to an Observable and provides callbacks to handle the items it emits and any error
notification it issues.
|
Subscription |
subscribe(Action1<? super T> onNext,
Action1<java.lang.Throwable> onError,
Action0 onCompleted)
Subscribes to an Observable and provides callbacks to handle the items it emits and any error or
completion notification it issues.
|
Subscription |
subscribe(Observer<? super T> observer)
Subscribes to an Observable and provides an Observer that implements functions to handle the items the
Observable emits and any error or completion notification it issues.
|
Subscription |
subscribe(Subscriber<? super T> subscriber)
Subscribes to an Observable and provides a Subscriber that implements functions to handle the items the
Observable emits and any error or completion notification it issues.
|
Observable<T> |
subscribeOn(Scheduler scheduler)
Asynchronously subscribes Observers to this Observable on the specified
Scheduler . |
Observable<T> |
subscribeOn(Scheduler scheduler,
boolean requestOn)
|
Observable<T> |
switchIfEmpty(Observable<? extends T> alternate)
Returns an Observable that emits the items emitted by the source Observable or the items of an alternate
Observable if the source Observable is empty.
|
<R> Observable<R> |
switchMap(Func1<? super T,? extends Observable<? extends R>> func)
Returns a new Observable by applying a function that you supply to each item emitted by the source
Observable that returns an Observable, and then emitting the items emitted by the most recently emitted
of these Observables.
|
<R> Observable<R> |
switchMapDelayError(Func1<? super T,? extends Observable<? extends R>> func)
Returns a new Observable by applying a function that you supply to each item emitted by the source
Observable that returns an Observable, and then emitting the items emitted by the most recently emitted
of these Observables and delays any error until all Observables terminate.
|
static <T> Observable<T> |
switchOnNext(Observable<? extends Observable<? extends T>> sequenceOfSequences)
Converts an Observable that emits Observables into an Observable that emits the items emitted by the
most recently emitted of those Observables.
|
static <T> Observable<T> |
switchOnNextDelayError(Observable<? extends Observable<? extends T>> sequenceOfSequences)
Converts an Observable that emits Observables into an Observable that emits the items emitted by the
most recently emitted of those Observables and delays any exception until all Observables terminate.
|
Observable<T> |
take(int count)
Returns an Observable that emits only the first
count items emitted by the source Observable. |
Observable<T> |
take(long time,
java.util.concurrent.TimeUnit unit)
Returns an Observable that emits those items emitted by source Observable before a specified time runs
out.
|
Observable<T> |
take(long time,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that emits those items emitted by source Observable before a specified time (on a
specified Scheduler) runs out.
|
Observable<T> |
takeFirst(Func1<? super T,java.lang.Boolean> predicate)
Returns an Observable that emits only the very first item emitted by the source Observable that satisfies
a specified condition.
|
Observable<T> |
takeLast(int count)
Returns an Observable that emits at most the last
count items emitted by the source Observable. |
Observable<T> |
takeLast(int count,
long time,
java.util.concurrent.TimeUnit unit)
Returns an Observable that emits at most a specified number of items from the source Observable that were
emitted in a specified window of time before the Observable completed.
|
Observable<T> |
takeLast(int count,
long time,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that emits at most a specified number of items from the source Observable that were
emitted in a specified window of time before the Observable completed, where the timing information is
provided by a given Scheduler.
|
Observable<T> |
takeLast(long time,
java.util.concurrent.TimeUnit unit)
Returns an Observable that emits the items from the source Observable that were emitted in a specified
window of time before the Observable completed.
|
Observable<T> |
takeLast(long time,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that emits the items from the source Observable that were emitted in a specified
window of time before the Observable completed, where the timing information is provided by a specified
Scheduler.
|
Observable<java.util.List<T>> |
takeLastBuffer(int count)
Returns an Observable that emits a single List containing at most the last
count elements emitted by the
source Observable. |
Observable<java.util.List<T>> |
takeLastBuffer(int count,
long time,
java.util.concurrent.TimeUnit unit)
Returns an Observable that emits a single List containing at most
count items from the source
Observable that were emitted during a specified window of time before the source Observable completed. |
Observable<java.util.List<T>> |
takeLastBuffer(int count,
long time,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that emits a single List containing at most
count items from the source
Observable that were emitted during a specified window of time (on a specified Scheduler) before the
source Observable completed. |
Observable<java.util.List<T>> |
takeLastBuffer(long time,
java.util.concurrent.TimeUnit unit)
Returns an Observable that emits a single List containing those items from the source Observable that
were emitted during a specified window of time before the source Observable completed.
|
Observable<java.util.List<T>> |
takeLastBuffer(long time,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that emits a single List containing those items from the source Observable that
were emitted during a specified window of time before the source Observable completed, where the timing
information is provided by the given Scheduler.
|
Observable<T> |
takeUntil(Func1<? super T,java.lang.Boolean> 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.
|
<E> Observable<T> |
takeUntil(Observable<? extends E> other)
Returns an Observable that emits the items emitted by the source Observable until a second Observable
emits an item.
|
Observable<T> |
takeWhile(Func1<? super T,java.lang.Boolean> predicate)
Returns an Observable that emits items emitted by the source Observable so long as each item satisfied a
specified condition, and then completes as soon as this condition is not satisfied.
|
AssertableSubscriber<T> |
test()
Creates a AssertableSubscriber that requests
Long.MAX_VALUE and subscribes
it to this Observable. |
AssertableSubscriber<T> |
test(long initialRequestAmount)
Creates an AssertableSubscriber with the initial request amount and subscribes
it to this Observable.
|
Observable<T> |
throttleFirst(long windowDuration,
java.util.concurrent.TimeUnit unit)
Returns an Observable that emits only the first item emitted by the source Observable during sequential
time windows of a specified duration.
|
Observable<T> |
throttleFirst(long skipDuration,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that emits only the first item emitted by the source Observable during sequential
time windows of a specified duration, where the windows are managed by a specified Scheduler.
|
Observable<T> |
throttleLast(long intervalDuration,
java.util.concurrent.TimeUnit unit)
Returns an Observable that emits only the last item emitted by the source Observable during sequential
time windows of a specified duration.
|
Observable<T> |
throttleLast(long intervalDuration,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that emits only the last item emitted by the source Observable during sequential
time windows of a specified duration, where the duration is governed by a specified Scheduler.
|
Observable<T> |
throttleWithTimeout(long timeout,
java.util.concurrent.TimeUnit unit)
Returns an Observable that only emits those items emitted by the source Observable that are not followed
by another emitted item within a specified time window.
|
Observable<T> |
throttleWithTimeout(long timeout,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that only emits those items emitted by the source Observable that are not followed
by another emitted item within a specified time window, where the time window is governed by a specified
Scheduler.
|
Observable<TimeInterval<T>> |
timeInterval()
Returns an Observable that emits records of the time interval between consecutive items emitted by the
source Observable.
|
Observable<TimeInterval<T>> |
timeInterval(Scheduler scheduler)
Returns an Observable that emits records of the time interval between consecutive items emitted by the
source Observable, where this interval is computed on a specified Scheduler.
|
<U,V> Observable<T> |
timeout(Func0<? extends Observable<U>> firstTimeoutSelector,
Func1<? super T,? extends Observable<V>> timeoutSelector)
Returns an Observable that mirrors the source Observable, but notifies observers of a
TimeoutException if either the first item emitted by the source Observable or any subsequent item
doesn't arrive within time windows defined by other Observables. |
<U,V> Observable<T> |
timeout(Func0<? extends Observable<U>> firstTimeoutSelector,
Func1<? super T,? extends Observable<V>> timeoutSelector,
Observable<? extends T> other)
Returns an Observable that mirrors the source Observable, but switches to a fallback Observable if either
the first item emitted by the source Observable or any subsequent item doesn't arrive within time windows
defined by other Observables.
|
<V> Observable<T> |
timeout(Func1<? super T,? extends Observable<V>> timeoutSelector)
Returns an Observable that mirrors the source Observable, but notifies observers of a
TimeoutException if an item emitted by the source Observable doesn't arrive within a window of
time after the emission of the previous item, where that period of time is measured by an Observable that
is a function of the previous item. |
<V> Observable<T> |
timeout(Func1<? super T,? extends Observable<V>> timeoutSelector,
Observable<? extends T> other)
Returns an Observable that mirrors the source Observable, but that switches to a fallback Observable if
an item emitted by the source Observable doesn't arrive within a window of time after the emission of the
previous item, where that period of time is measured by an Observable that is a function of the previous
item.
|
Observable<T> |
timeout(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Returns an Observable that mirrors the source Observable but applies a timeout policy for each emitted
item.
|
Observable<T> |
timeout(long timeout,
java.util.concurrent.TimeUnit timeUnit,
Observable<? extends T> other)
Returns an Observable that mirrors the source Observable but applies a timeout policy for each emitted
item.
|
Observable<T> |
timeout(long timeout,
java.util.concurrent.TimeUnit timeUnit,
Observable<? extends T> other,
Scheduler scheduler)
Returns an Observable that mirrors the source Observable but applies a timeout policy for each emitted
item using a specified Scheduler.
|
Observable<T> |
timeout(long timeout,
java.util.concurrent.TimeUnit timeUnit,
Scheduler scheduler)
Returns an Observable that mirrors the source Observable but applies a timeout policy for each emitted
item, where this policy is governed on a specified Scheduler.
|
static Observable<java.lang.Long> |
timer(long initialDelay,
long period,
java.util.concurrent.TimeUnit unit)
Deprecated.
use
interval(long, long, TimeUnit) instead |
static Observable<java.lang.Long> |
timer(long initialDelay,
long period,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Deprecated.
use
interval(long, long, TimeUnit, Scheduler) instead |
static Observable<java.lang.Long> |
timer(long delay,
java.util.concurrent.TimeUnit unit)
Returns an Observable that emits
0L after a specified delay, and then completes. |
static Observable<java.lang.Long> |
timer(long delay,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that emits
0L after a specified delay, on a specified Scheduler, and then
completes. |
Observable<Timestamped<T>> |
timestamp()
Returns an Observable that emits each item emitted by the source Observable, wrapped in a
Timestamped object. |
Observable<Timestamped<T>> |
timestamp(Scheduler scheduler)
Returns an Observable that emits each item emitted by the source Observable, wrapped in a
Timestamped object whose timestamps are provided by a specified Scheduler. |
<R> R |
to(Func1<? super Observable<T>,R> converter)
Calls the specified converter function during assembly time and returns its resulting value.
|
BlockingObservable<T> |
toBlocking()
Converts an Observable into a
BlockingObservable (an Observable with blocking operators). |
Completable |
toCompletable()
Returns a Completable that discards all onNext emissions (similar to
ignoreAllElements() ) and calls onCompleted when this source observable calls
onCompleted. |
Observable<java.util.List<T>> |
toList()
Returns an Observable that emits a single item, a list composed of all the items emitted by the source
Observable.
|
<K> Observable<java.util.Map<K,T>> |
toMap(Func1<? super T,? extends K> keySelector)
Returns an Observable that emits a single HashMap containing all items emitted by the source Observable,
mapped by the keys returned by a specified
keySelector function. |
<K,V> Observable<java.util.Map<K,V>> |
toMap(Func1<? super T,? extends K> keySelector,
Func1<? super T,? extends V> valueSelector)
Returns an Observable that emits a single HashMap containing values corresponding to items emitted by the
source Observable, mapped by the keys returned by a specified
keySelector function. |
<K,V> Observable<java.util.Map<K,V>> |
toMap(Func1<? super T,? extends K> keySelector,
Func1<? super T,? extends V> valueSelector,
Func0<? extends java.util.Map<K,V>> mapFactory)
Returns an Observable that emits a single Map, returned by a specified
mapFactory function, that
contains keys and values extracted from the items emitted by the source Observable. |
<K> Observable<java.util.Map<K,java.util.Collection<T>>> |
toMultimap(Func1<? super T,? extends K> keySelector)
Returns an Observable that emits a single HashMap that contains an ArrayList of items emitted by the
source Observable keyed by a specified
keySelector function. |
<K,V> Observable<java.util.Map<K,java.util.Collection<V>>> |
toMultimap(Func1<? super T,? extends K> keySelector,
Func1<? super T,? extends V> valueSelector)
Returns an Observable that emits a single HashMap that contains an ArrayList of values extracted by a
specified
valueSelector function from items emitted by the source Observable, keyed by a
specified keySelector function. |
<K,V> Observable<java.util.Map<K,java.util.Collection<V>>> |
toMultimap(Func1<? super T,? extends K> keySelector,
Func1<? super T,? extends V> valueSelector,
Func0<? extends java.util.Map<K,java.util.Collection<V>>> mapFactory)
Returns an Observable that emits a single Map, returned by a specified
mapFactory function, that
contains an ArrayList of values, extracted by a specified valueSelector function from items
emitted by the source Observable and keyed by the keySelector function. |
<K,V> Observable<java.util.Map<K,java.util.Collection<V>>> |
toMultimap(Func1<? super T,? extends K> keySelector,
Func1<? super T,? extends V> valueSelector,
Func0<? extends java.util.Map<K,java.util.Collection<V>>> mapFactory,
Func1<? super K,? extends java.util.Collection<V>> collectionFactory)
Returns an Observable that emits a single Map, returned by a specified
mapFactory function, that
contains a custom collection of values, extracted by a specified valueSelector function from
items emitted by the source Observable, and keyed by the keySelector function. |
Single<T> |
toSingle()
Returns a Single that emits the single item emitted by the source Observable, if that Observable
emits only a single item.
|
Observable<java.util.List<T>> |
toSortedList()
Returns an Observable that emits a list that contains the items emitted by the source Observable, in a
sorted order.
|
Observable<java.util.List<T>> |
toSortedList(Func2<? super T,? super T,java.lang.Integer> sortFunction)
Returns an Observable that emits a list that contains the items emitted by the source Observable, in a
sorted order based on a specified comparison function.
|
Observable<java.util.List<T>> |
toSortedList(Func2<? super T,? super T,java.lang.Integer> sortFunction,
int initialCapacity)
Returns an Observable that emits a list that contains the items emitted by the source Observable, in a
sorted order based on a specified comparison function.
|
Observable<java.util.List<T>> |
toSortedList(int initialCapacity)
Returns an Observable that emits a list that contains the items emitted by the source Observable, in a
sorted order.
|
static <T> Observable<T> |
unsafeCreate(Observable.OnSubscribe<T> f)
Returns an Observable that executes the given OnSubscribe action for each individual Subscriber
that subscribes; unsubscription and backpressure must be implemented manually.
|
Subscription |
unsafeSubscribe(Subscriber<? super T> subscriber)
Subscribes to an Observable and invokes
Observable.OnSubscribe function without any contract protection,
error handling, unsubscribe, or execution hooks. |
Observable<T> |
unsubscribeOn(Scheduler scheduler)
Modifies the source Observable so that subscribers will unsubscribe from it on a specified
Scheduler . |
static <T,Resource> |
using(Func0<Resource> resourceFactory,
Func1<? super Resource,? extends Observable<? extends T>> observableFactory,
Action1<? super Resource> disposeAction)
Constructs an Observable that creates a dependent resource object which is disposed of on unsubscription.
|
static <T,Resource> |
using(Func0<Resource> resourceFactory,
Func1<? super Resource,? extends Observable<? extends T>> observableFactory,
Action1<? super Resource> disposeAction,
boolean disposeEagerly)
Constructs an Observable that creates a dependent resource object which is disposed of just before
termination if you have set
disposeEagerly to true and unsubscription does not occur
before termination. |
<TClosing> Observable<Observable<T>> |
window(Func0<? extends Observable<? extends TClosing>> closingSelector)
Returns an Observable that emits windows of items it collects from the source Observable.
|
Observable<Observable<T>> |
window(int count)
Returns an Observable that emits windows of items it collects from the source Observable.
|
Observable<Observable<T>> |
window(int count,
int skip)
Returns an Observable that emits windows of items it collects from the source Observable.
|
Observable<Observable<T>> |
window(long timespan,
long timeshift,
java.util.concurrent.TimeUnit unit)
Returns an Observable that emits windows of items it collects from the source Observable.
|
Observable<Observable<T>> |
window(long timespan,
long timeshift,
java.util.concurrent.TimeUnit unit,
int count,
Scheduler scheduler)
Returns an Observable that emits windows of items it collects from the source Observable.
|
Observable<Observable<T>> |
window(long timespan,
long timeshift,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that emits windows of items it collects from the source Observable.
|
Observable<Observable<T>> |
window(long timespan,
java.util.concurrent.TimeUnit unit)
Returns an Observable that emits windows of items it collects from the source Observable.
|
Observable<Observable<T>> |
window(long timespan,
java.util.concurrent.TimeUnit unit,
int count)
Returns an Observable that emits windows of items it collects from the source Observable.
|
Observable<Observable<T>> |
window(long timespan,
java.util.concurrent.TimeUnit unit,
int count,
Scheduler scheduler)
Returns an Observable that emits windows of items it collects from the source Observable.
|
Observable<Observable<T>> |
window(long timespan,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
Returns an Observable that emits windows of items it collects from the source Observable.
|
<TOpening,TClosing> |
window(Observable<? extends TOpening> windowOpenings,
Func1<? super TOpening,? extends Observable<? extends TClosing>> closingSelector)
Returns an Observable that emits windows of items it collects from the source Observable.
|
<U> Observable<Observable<T>> |
window(Observable<U> boundary)
Returns an Observable that emits non-overlapping windows of items it collects from the source Observable
where the boundary of each window is determined by the items emitted from a specified boundary-governing
Observable.
|
<R> Observable<R> |
withLatestFrom(java.lang.Iterable<Observable<?>> others,
FuncN<R> combiner)
Combines the value emission from this Observable with the latest emissions from the
other Observables via a function to produce the output item.
|
<R> Observable<R> |
withLatestFrom(Observable<?>[] others,
FuncN<R> combiner)
Combines the value emission from this Observable with the latest emissions from the
other Observables via a function to produce the output item.
|
<U,R> Observable<R> |
withLatestFrom(Observable<? extends U> other,
Func2<? super T,? super U,? extends R> resultSelector)
Merges the specified Observable into this Observable sequence by using the
resultSelector
function only when the source Observable (this instance) emits an item. |
<T1,T2,R> Observable<R> |
withLatestFrom(Observable<T1> o1,
Observable<T2> o2,
Func3<? super T,? super T1,? super T2,R> combiner)
Combines the value emission from this Observable with the latest emissions from the
other Observables via a function to produce the output item.
|
<T1,T2,T3,R> |
withLatestFrom(Observable<T1> o1,
Observable<T2> o2,
Observable<T3> o3,
Func4<? super T,? super T1,? super T2,? super T3,R> combiner)
Combines the value emission from this Observable with the latest emissions from the
other Observables via a function to produce the output item.
|
<T1,T2,T3,T4,R> |
withLatestFrom(Observable<T1> o1,
Observable<T2> o2,
Observable<T3> o3,
Observable<T4> o4,
Func5<? super T,? super T1,? super T2,? super T3,? super T4,R> combiner)
Combines the value emission from this Observable with the latest emissions from the
other Observables via a function to produce the output item.
|
<T1,T2,T3,T4,T5,R> |
withLatestFrom(Observable<T1> o1,
Observable<T2> o2,
Observable<T3> o3,
Observable<T4> o4,
Observable<T5> o5,
Func6<? super T,? super T1,? super T2,? super T3,? super T4,? super T5,R> combiner)
Combines the value emission from this Observable with the latest emissions from the
other Observables via a function to produce the output item.
|
<T1,T2,T3,T4,T5,T6,R> |
withLatestFrom(Observable<T1> o1,
Observable<T2> o2,
Observable<T3> o3,
Observable<T4> o4,
Observable<T5> o5,
Observable<T6> o6,
Func7<? super T,? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,R> combiner)
Combines the value emission from this Observable with the latest emissions from the
other Observables via a function to produce the output item.
|
<T1,T2,T3,T4,T5,T6,T7,R> |
withLatestFrom(Observable<T1> o1,
Observable<T2> o2,
Observable<T3> o3,
Observable<T4> o4,
Observable<T5> o5,
Observable<T6> o6,
Observable<T7> o7,
Func8<? super T,? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,R> combiner)
Combines the value emission from this Observable with the latest emissions from the
other Observables via a function to produce the output item.
|
<T1,T2,T3,T4,T5,T6,T7,T8,R> |
withLatestFrom(Observable<T1> o1,
Observable<T2> o2,
Observable<T3> o3,
Observable<T4> o4,
Observable<T5> o5,
Observable<T6> o6,
Observable<T7> o7,
Observable<T8> o8,
Func9<? super T,? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,R> combiner)
Combines the value emission from this Observable with the latest emissions from the
other Observables via a function to produce the output item.
|
static <R> Observable<R> |
zip(java.lang.Iterable<? extends Observable<?>> ws,
FuncN<? extends R> zipFunction)
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 Observables.
|
static <R> Observable<R> |
zip(Observable<?>[] ws,
FuncN<? extends R> zipFunction)
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 Observables.
|
static <R> Observable<R> |
zip(Observable<? extends Observable<?>> ws,
FuncN<? extends R> zipFunction)
Returns an Observable that emits the results of a specified combiner function applied to combinations of
n items emitted, in sequence, by the n Observables emitted by a specified Observable.
|
static <T1,T2,R> Observable<R> |
zip(Observable<? extends T1> o1,
Observable<? extends T2> o2,
Func2<? super T1,? super T2,? extends R> zipFunction)
Returns an Observable that emits the results of a specified combiner function applied to combinations of
two items emitted, in sequence, by two other Observables.
|
static <T1,T2,T3,R> |
zip(Observable<? extends T1> o1,
Observable<? extends T2> o2,
Observable<? extends T3> o3,
Func3<? super T1,? super T2,? super T3,? extends R> zipFunction)
Returns an Observable that emits the results of a specified combiner function applied to combinations of
three items emitted, in sequence, by three other Observables.
|
static <T1,T2,T3,T4,R> |
zip(Observable<? extends T1> o1,
Observable<? extends T2> o2,
Observable<? extends T3> o3,
Observable<? extends T4> o4,
Func4<? super T1,? super T2,? super T3,? super T4,? extends R> zipFunction)
Returns an Observable that emits the results of a specified combiner function applied to combinations of
four items emitted, in sequence, by four other Observables.
|
static <T1,T2,T3,T4,T5,R> |
zip(Observable<? extends T1> o1,
Observable<? extends T2> o2,
Observable<? extends T3> o3,
Observable<? extends T4> o4,
Observable<? extends T5> o5,
Func5<? super T1,? super T2,? super T3,? super T4,? super T5,? extends R> zipFunction)
Returns an Observable that emits the results of a specified combiner function applied to combinations of
five items emitted, in sequence, by five other Observables.
|
static <T1,T2,T3,T4,T5,T6,R> |
zip(Observable<? extends T1> o1,
Observable<? extends T2> o2,
Observable<? extends T3> o3,
Observable<? extends T4> o4,
Observable<? extends T5> o5,
Observable<? extends T6> o6,
Func6<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? extends R> zipFunction)
Returns an Observable that emits the results of a specified combiner function applied to combinations of
six items emitted, in sequence, by six other Observables.
|
static <T1,T2,T3,T4,T5,T6,T7,R> |
zip(Observable<? extends T1> o1,
Observable<? extends T2> o2,
Observable<? extends T3> o3,
Observable<? extends T4> o4,
Observable<? extends T5> o5,
Observable<? extends T6> o6,
Observable<? extends T7> o7,
Func7<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? extends R> zipFunction)
Returns an Observable that emits the results of a specified combiner function applied to combinations of
seven items emitted, in sequence, by seven other Observables.
|
static <T1,T2,T3,T4,T5,T6,T7,T8,R> |
zip(Observable<? extends T1> o1,
Observable<? extends T2> o2,
Observable<? extends T3> o3,
Observable<? extends T4> o4,
Observable<? extends T5> o5,
Observable<? extends T6> o6,
Observable<? extends T7> o7,
Observable<? extends T8> o8,
Func8<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? extends R> zipFunction)
Returns an Observable that emits the results of a specified combiner function applied to combinations of
eight items emitted, in sequence, by eight other Observables.
|
static <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> |
zip(Observable<? extends T1> o1,
Observable<? extends T2> o2,
Observable<? extends T3> o3,
Observable<? extends T4> o4,
Observable<? extends T5> o5,
Observable<? extends T6> o6,
Observable<? extends T7> o7,
Observable<? extends T8> o8,
Observable<? extends T9> o9,
Func9<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? super T9,? extends R> zipFunction)
Returns an Observable that emits the results of a specified combiner function applied to combinations of
nine items emitted, in sequence, by nine other Observables.
|
<T2,R> Observable<R> |
zipWith(java.lang.Iterable<? extends T2> other,
Func2<? super T,? super T2,? extends R> zipFunction)
Returns an Observable that emits items that are the result of applying a specified function to pairs of
values, one each from the source Observable and a specified Iterable sequence.
|
<T2,R> Observable<R> |
zipWith(Observable<? extends T2> other,
Func2<? super T,? super T2,? extends R> zipFunction)
Returns an Observable that emits items that are the result of applying a specified function to pairs of
values, one each from the source Observable and another specified Observable.
|
protected Observable(Observable.OnSubscribe<T> f)
Note: Use unsafeCreate(OnSubscribe)
to create an Observable, instead of this constructor,
unless you specifically have a need for inheritance.
f
- Observable.OnSubscribe
to be executed when subscribe(Subscriber)
is called@Deprecated public static <T> Observable<T> create(Observable.OnSubscribe<T> f)
unsafeCreate(OnSubscribe)
for advanced cases (such as custom operators)T
- the value type emittedf
- the callback to execute for each individual Subscriber that subscribes to the
returned Observablecreate(SyncOnSubscribe)
,
create(AsyncOnSubscribe)
,
create(Action1, rx.Emitter.BackpressureMode)
public static <T> Observable<T> create(Action1<Emitter<T>> emitter, Emitter.BackpressureMode backpressure)
Example:
Observable.<Event>create(emitter -> {
Callback listener = new Callback() {
@Override
public void onEvent(Event e) {
emitter.onNext(e);
if (e.isLast()) {
emitter.onCompleted();
}
}
@Override
public void onFailure(Exception e) {
emitter.onError(e);
}
};
AutoCloseable c = api.someMethod(listener);
emitter.setCancellation(c::close);
}, BackpressureMode.BUFFER);
You should call the Emitter's onNext, onError and onCompleted methods in a serialized fashion. The rest of its methods are thread-safe.
History: 1.2.7 - experimental
T
- the element typeemitter
- the emitter that is called when a Subscriber subscribes to the returned Observable
backpressure
- the backpressure mode to apply if the downstream Subscriber doesn't request (fast) enoughEmitter
,
Emitter.BackpressureMode
,
Cancellable
public static <T> Observable<T> unsafeCreate(Observable.OnSubscribe<T> f)
Write the function you pass to create
so that it behaves as an Observable: It should invoke the
Subscriber's onNext
, onError
, and
onCompleted
methods appropriately.
A well-formed Observable must invoke either the Subscriber's onCompleted
method exactly once or
its onError
method exactly once.
See Rx Design Guidelines (PDF) for detailed information.
OnSubscribe
instance provided is responsible to be backpressure-aware or
document the fact that the consumer of the returned Observable
has to apply one of
the onBackpressureXXX
operators.unsafeCreate
does not operate by default on a particular Scheduler
.History: 1.2.7 - experimental
T
- the type of the items that this Observable emitsf
- a function that accepts an Subscriber<T>
, and invokes its onNext
,
onError
, and onCompleted
methods as appropriateSubscriber
subscribes to it, will execute the specified
functionpublic static <S,T> Observable<T> create(SyncOnSubscribe<S,T> syncOnSubscribe)
SyncOnSubscribe
's life cycle for
generating events.
Note: the SyncOnSubscribe
provides a generic way to fulfill data by iterating
over a (potentially stateful) function (e.g. reading data off of a channel, a parser, ). If your
data comes directly from an asynchronous/potentially concurrent source then consider using the
asynchronous overload
.
See Rx Design Guidelines (PDF) for detailed information.
create
does not operate by default on a particular Scheduler
.T
- the type of the items that this Observable emitsS
- the state typesyncOnSubscribe
- an implementation of SyncOnSubscribe
. There are many static creation methods
on the class for convenience.Subscriber
subscribes to it, will execute the specified
functionSyncOnSubscribe.createSingleState(Func0, Action2)
,
SyncOnSubscribe.createSingleState(Func0, Action2, Action1)
,
SyncOnSubscribe.createStateful(Func0, Func2)
,
SyncOnSubscribe.createStateful(Func0, Func2, Action1)
,
SyncOnSubscribe.createStateless(Action1)
,
SyncOnSubscribe.createStateless(Action1, Action0)
,
ReactiveX operators documentation: Create@Beta public static <S,T> Observable<T> create(AsyncOnSubscribe<S,T> asyncOnSubscribe)
AsyncOnSubscribe
's life cycle for
generating events.
Note: the AsyncOnSubscribe
is useful for observable sources of data that are
necessarily asynchronous (RPC, external services, etc). Typically most use cases can be solved
with the synchronous overload
.
See Rx Design Guidelines (PDF) for detailed information.
create
does not operate by default on a particular Scheduler
.T
- the type of the items that this Observable emitsS
- the state typeasyncOnSubscribe
- an implementation of AsyncOnSubscribe
. There are many static creation methods
on the class for convenience.Subscriber
subscribes to it, will execute the specified
functionAsyncOnSubscribe.createSingleState(Func0, Action3)
,
AsyncOnSubscribe.createSingleState(Func0, Action3, Action1)
,
AsyncOnSubscribe.createStateful(Func0, Func3)
,
AsyncOnSubscribe.createStateful(Func0, Func3, Action1)
,
AsyncOnSubscribe.createStateless(Action2)
,
AsyncOnSubscribe.createStateless(Action2, Action0)
,
ReactiveX operators documentation: Createpublic final <R> Observable<R> lift(Observable.Operator<? extends R,? super T> operator)
In other words, this allows chaining Observers together on an Observable for acting on the values within the Observable.
observable.map(...).filter(...).take(5).lift(new OperatorA()).lift(new OperatorB(...)).subscribe()
If the operator you are creating is designed to act on the individual items emitted by a source
Observable, use lift
. If your operator is designed to transform the source Observable as a whole
(for instance, by applying a particular set of existing RxJava operators to it) use compose(rx.Observable.Transformer<? super T, ? extends R>)
.
Operator
instance provided is responsible to be backpressure-aware or
document the fact that the consumer of the returned Observable
has to apply one of
the onBackpressureXXX
operators.lift
does not operate by default on a particular Scheduler
.R
- the output value typeoperator
- the Operator that implements the Observable-operating function to be applied to the source
Observablepublic <R> Observable<R> compose(Observable.Transformer<? super T,? extends R> transformer)
This method operates on the Observable itself whereas lift(rx.Observable.Operator<? extends R, ? super T>)
operates on the Observable's
Subscribers or Observers.
If the operator you are creating is designed to act on the individual items emitted by a source
Observable, use lift(rx.Observable.Operator<? extends R, ? super T>)
. If your operator is designed to transform the source Observable as a whole
(for instance, by applying a particular set of existing RxJava operators to it) use compose
.
Observable
the transformer returns.compose
does not operate by default on a particular Scheduler
.R
- the value type of the output Observabletransformer
- implements the function that transforms the source Observablepublic final <R> R to(Func1<? super Observable<T>,R> converter)
This allows fluent conversion to any other type.
R
- the resulting object typeconverter
- the function that receives the current Observable instance and returns a valuepublic Single<T> toSingle()
IllegalArgumentException
or NoSuchElementException
respectively.
Observable
and the returned Single
does not have a notion of backpressure.toSingle
does not operate by default on a particular Scheduler
.java.lang.IllegalArgumentException
- if the source observable emits more than one itemjava.util.NoSuchElementException
- if the source observable emits no itemspublic Completable toCompletable()
ignoreAllElements()
) and calls onCompleted when this source observable calls
onCompleted. Error terminal events are propagated.
Observable
and the returned Completable
does not have a notion of backpressure.toCompletable
does not operate by default on a particular Scheduler
.public static <T> Observable<T> amb(java.lang.Iterable<? extends Observable<? extends T>> sources)
Observable
's backpressure behavior.amb
does not operate by default on a particular Scheduler
.T
- the common element typesources
- an Iterable of Observable sources competing to react firstpublic static <T> Observable<T> amb(Observable<? extends T> o1, Observable<? extends T> o2)
Observable
's backpressure behavior.amb
does not operate by default on a particular Scheduler
.T
- the common element typeo1
- an Observable competing to react firsto2
- an Observable competing to react firstpublic static <T> Observable<T> amb(Observable<? extends T> o1, Observable<? extends T> o2, Observable<? extends T> o3)
Observable
's backpressure behavior.amb
does not operate by default on a particular Scheduler
.T
- the common element base typeo1
- an Observable competing to react firsto2
- an Observable competing to react firsto3
- an Observable competing to react firstpublic static <T> Observable<T> amb(Observable<? extends T> o1, Observable<? extends T> o2, Observable<? extends T> o3, Observable<? extends T> o4)
Observable
's backpressure behavior.amb
does not operate by default on a particular Scheduler
.T
- the common element base typeo1
- an Observable competing to react firsto2
- an Observable competing to react firsto3
- an Observable competing to react firsto4
- an Observable competing to react firstpublic static <T> Observable<T> amb(Observable<? extends T> o1, Observable<? extends T> o2, Observable<? extends T> o3, Observable<? extends T> o4, Observable<? extends T> o5)
Observable
's backpressure behavior.amb
does not operate by default on a particular Scheduler
.T
- the common element base typeo1
- an Observable competing to react firsto2
- an Observable competing to react firsto3
- an Observable competing to react firsto4
- an Observable competing to react firsto5
- an Observable competing to react firstpublic static <T> Observable<T> amb(Observable<? extends T> o1, Observable<? extends T> o2, Observable<? extends T> o3, Observable<? extends T> o4, Observable<? extends T> o5, Observable<? extends T> o6)
Observable
's backpressure behavior.amb
does not operate by default on a particular Scheduler
.T
- the common element base typeo1
- an Observable competing to react firsto2
- an Observable competing to react firsto3
- an Observable competing to react firsto4
- an Observable competing to react firsto5
- an Observable competing to react firsto6
- an Observable competing to react firstpublic static <T> Observable<T> amb(Observable<? extends T> o1, Observable<? extends T> o2, Observable<? extends T> o3, Observable<? extends T> o4, Observable<? extends T> o5, Observable<? extends T> o6, Observable<? extends T> o7)
Observable
's backpressure behavior.amb
does not operate by default on a particular Scheduler
.T
- the common element base typeo1
- an Observable competing to react firsto2
- an Observable competing to react firsto3
- an Observable competing to react firsto4
- an Observable competing to react firsto5
- an Observable competing to react firsto6
- an Observable competing to react firsto7
- an Observable competing to react firstpublic static <T> Observable<T> amb(Observable<? extends T> o1, Observable<? extends T> o2, Observable<? extends T> o3, Observable<? extends T> o4, Observable<? extends T> o5, Observable<? extends T> o6, Observable<? extends T> o7, Observable<? extends T> o8)
Observable
's backpressure behavior.amb
does not operate by default on a particular Scheduler
.T
- the common element base typeo1
- an Observable competing to react firsto2
- an Observable competing to react firsto3
- an Observable competing to react firsto4
- an Observable competing to react firsto5
- an Observable competing to react firsto6
- an Observable competing to react firsto7
- an Observable competing to react firsto8
- an observable competing to react firstpublic static <T> Observable<T> amb(Observable<? extends T> o1, Observable<? extends T> o2, Observable<? extends T> o3, Observable<? extends T> o4, Observable<? extends T> o5, Observable<? extends T> o6, Observable<? extends T> o7, Observable<? extends T> o8, Observable<? extends T> o9)
Observable
's backpressure behavior.amb
does not operate by default on a particular Scheduler
.T
- the common element base typeo1
- an Observable competing to react firsto2
- an Observable competing to react firsto3
- an Observable competing to react firsto4
- an Observable competing to react firsto5
- an Observable competing to react firsto6
- an Observable competing to react firsto7
- an Observable competing to react firsto8
- an Observable competing to react firsto9
- an Observable competing to react firstpublic static <T1,T2,R> Observable<R> combineLatest(Observable<? extends T1> o1, Observable<? extends T2> o2, Func2<? super T1,? super T2,? extends R> combineFunction)
Observable
honors backpressure from downstream. The source Observable
s
are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signal
MissingBackpressureException
) and may lead to OutOfMemoryError
due to internal buffer bloat.combineLatest
does not operate by default on a particular Scheduler
.T1
- the element type of the first sourceT2
- the element type of the second sourceR
- the combined output typeo1
- the first source Observableo2
- the second source ObservablecombineFunction
- the aggregation function used to combine the items emitted by the source Observablespublic static <T1,T2,T3,R> Observable<R> combineLatest(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Func3<? super T1,? super T2,? super T3,? extends R> combineFunction)
Observable
honors backpressure from downstream. The source Observable
s
are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signal
MissingBackpressureException
) and may lead to OutOfMemoryError
due to internal buffer bloat.combineLatest
does not operate by default on a particular Scheduler
.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 typeo1
- the first source Observableo2
- the second source Observableo3
- the third source ObservablecombineFunction
- the aggregation function used to combine the items emitted by the source Observablespublic static <T1,T2,T3,T4,R> Observable<R> combineLatest(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Func4<? super T1,? super T2,? super T3,? super T4,? extends R> combineFunction)
Observable
honors backpressure from downstream. The source Observable
s
are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signal
MissingBackpressureException
) and may lead to OutOfMemoryError
due to internal buffer bloat.combineLatest
does not operate by default on a particular Scheduler
.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 typeo1
- the first source Observableo2
- the second source Observableo3
- the third source Observableo4
- the fourth source ObservablecombineFunction
- the aggregation function used to combine the items emitted by the source Observablespublic static <T1,T2,T3,T4,T5,R> Observable<R> combineLatest(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Func5<? super T1,? super T2,? super T3,? super T4,? super T5,? extends R> combineFunction)
Observable
honors backpressure from downstream. The source Observable
s
are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signal
MissingBackpressureException
) and may lead to OutOfMemoryError
due to internal buffer bloat.combineLatest
does not operate by default on a particular Scheduler
.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 typeo1
- the first source Observableo2
- the second source Observableo3
- the third source Observableo4
- the fourth source Observableo5
- the fifth source ObservablecombineFunction
- the aggregation function used to combine the items emitted by the source Observablespublic static <T1,T2,T3,T4,T5,T6,R> Observable<R> combineLatest(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Observable<? extends T6> o6, Func6<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? extends R> combineFunction)
Observable
honors backpressure from downstream. The source Observable
s
are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signal
MissingBackpressureException
) and may lead to OutOfMemoryError
due to internal buffer bloat.combineLatest
does not operate by default on a particular Scheduler
.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 typeo1
- the first source Observableo2
- the second source Observableo3
- the third source Observableo4
- the fourth source Observableo5
- the fifth source Observableo6
- the sixth source ObservablecombineFunction
- the aggregation function used to combine the items emitted by the source Observablespublic static <T1,T2,T3,T4,T5,T6,T7,R> Observable<R> combineLatest(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Observable<? extends T6> o6, Observable<? extends T7> o7, Func7<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? extends R> combineFunction)
Observable
honors backpressure from downstream. The source Observable
s
are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signal
MissingBackpressureException
) and may lead to OutOfMemoryError
due to internal buffer bloat.combineLatest
does not operate by default on a particular Scheduler
.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 typeo1
- the first source Observableo2
- the second source Observableo3
- the third source Observableo4
- the fourth source Observableo5
- the fifth source Observableo6
- the sixth source Observableo7
- the seventh source ObservablecombineFunction
- the aggregation function used to combine the items emitted by the source Observablespublic static <T1,T2,T3,T4,T5,T6,T7,T8,R> Observable<R> combineLatest(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Observable<? extends T6> o6, Observable<? extends T7> o7, Observable<? extends T8> o8, Func8<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? extends R> combineFunction)
Observable
honors backpressure from downstream. The source Observable
s
are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signal
MissingBackpressureException
) and may lead to OutOfMemoryError
due to internal buffer bloat.combineLatest
does not operate by default on a particular Scheduler
.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 typeo1
- the first source Observableo2
- the second source Observableo3
- the third source Observableo4
- the fourth source Observableo5
- the fifth source Observableo6
- the sixth source Observableo7
- the seventh source Observableo8
- the eighth source ObservablecombineFunction
- the aggregation function used to combine the items emitted by the source Observablespublic static <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> Observable<R> combineLatest(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Observable<? extends T6> o6, Observable<? extends T7> o7, Observable<? extends T8> o8, Observable<? extends T9> o9, Func9<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? super T9,? extends R> combineFunction)
Observable
honors backpressure from downstream. The source Observable
s
are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signal
MissingBackpressureException
) and may lead to OutOfMemoryError
due to internal buffer bloat.combineLatest
does not operate by default on a particular Scheduler
.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 typeo1
- the first source Observableo2
- the second source Observableo3
- the third source Observableo4
- the fourth source Observableo5
- the fifth source Observableo6
- the sixth source Observableo7
- the seventh source Observableo8
- the eighth source Observableo9
- the ninth source ObservablecombineFunction
- the aggregation function used to combine the items emitted by the source Observablespublic static <T,R> Observable<R> combineLatest(java.util.List<? extends Observable<? extends T>> sources, FuncN<? extends R> combineFunction)
Observable
honors backpressure from downstream. The source Observable
s
are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signal
MissingBackpressureException
) and may lead to OutOfMemoryError
due to internal buffer bloat.combineLatest
does not operate by default on a particular Scheduler
.T
- the common base type of source valuesR
- the result typesources
- the list of source ObservablescombineFunction
- the aggregation function used to combine the items emitted by the source Observablespublic static <T,R> Observable<R> combineLatest(java.lang.Iterable<? extends Observable<? extends T>> sources, FuncN<? extends R> combineFunction)
Observable
honors backpressure from downstream. The source Observable
s
are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signal
MissingBackpressureException
) and may lead to OutOfMemoryError
due to internal buffer bloat.combineLatest
does not operate by default on a particular Scheduler
.T
- the common base type of source valuesR
- the result typesources
- the collection of source ObservablescombineFunction
- the aggregation function used to combine the items emitted by the source Observablespublic static <T,R> Observable<R> combineLatestDelayError(java.lang.Iterable<? extends Observable<? extends T>> sources, FuncN<? extends R> combineFunction)
Observable
honors backpressure from downstream. The source Observable
s
are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signal
MissingBackpressureException
) and may lead to OutOfMemoryError
due to internal buffer bloat.combineLatest
does not operate by default on a particular Scheduler
.T
- the common base type of source valuesR
- the result typesources
- the collection of source ObservablescombineFunction
- the aggregation function used to combine the items emitted by the source Observablespublic static <T> Observable<T> concat(java.lang.Iterable<? extends Observable<? extends T>> sequences)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.concat
does not operate by default on a particular Scheduler
.T
- the common element base typesequences
- the Iterable of Observablespublic static <T> Observable<T> concat(Observable<? extends Observable<? extends T>> observables)
Observable
sources are expected to honor backpressure as well. If the outer violates this, a
MissingBackpressureException
is signalled. If any of the inner Observable
s violates
this, it may throw an IllegalStateException
when an inner Observable
completes.concat
does not operate by default on a particular Scheduler
.T
- the common element base typeobservables
- an Observable that emits Observablesobservables
, one after the other, without interleaving thempublic static <T> Observable<T> concat(Observable<? extends T> t1, Observable<? extends T> t2)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.concat
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be concatenatedt2
- an Observable to be concatenatedpublic static <T> Observable<T> concat(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.concat
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be concatenatedt2
- an Observable to be concatenatedt3
- an Observable to be concatenatedpublic static <T> Observable<T> concat(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.concat
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be concatenatedt2
- an Observable to be concatenatedt3
- an Observable to be concatenatedt4
- an Observable to be concatenatedpublic static <T> Observable<T> concat(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.concat
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be concatenatedt2
- an Observable to be concatenatedt3
- an Observable to be concatenatedt4
- an Observable to be concatenatedt5
- an Observable to be concatenatedpublic static <T> Observable<T> concat(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5, Observable<? extends T> t6)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.concat
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be concatenatedt2
- an Observable to be concatenatedt3
- an Observable to be concatenatedt4
- an Observable to be concatenatedt5
- an Observable to be concatenatedt6
- an Observable to be concatenatedpublic static <T> Observable<T> concat(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5, Observable<? extends T> t6, Observable<? extends T> t7)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.concat
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be concatenatedt2
- an Observable to be concatenatedt3
- an Observable to be concatenatedt4
- an Observable to be concatenatedt5
- an Observable to be concatenatedt6
- an Observable to be concatenatedt7
- an Observable to be concatenatedpublic static <T> Observable<T> concat(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5, Observable<? extends T> t6, Observable<? extends T> t7, Observable<? extends T> t8)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.concat
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be concatenatedt2
- an Observable to be concatenatedt3
- an Observable to be concatenatedt4
- an Observable to be concatenatedt5
- an Observable to be concatenatedt6
- an Observable to be concatenatedt7
- an Observable to be concatenatedt8
- an Observable to be concatenatedpublic static <T> Observable<T> concat(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5, Observable<? extends T> t6, Observable<? extends T> t7, Observable<? extends T> t8, Observable<? extends T> t9)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.concat
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be concatenatedt2
- an Observable to be concatenatedt3
- an Observable to be concatenatedt4
- an Observable to be concatenatedt5
- an Observable to be concatenatedt6
- an Observable to be concatenatedt7
- an Observable to be concatenatedt8
- an Observable to be concatenatedt9
- an Observable to be concatenatedpublic static <T> Observable<T> concatDelayError(Observable<? extends Observable<? extends T>> sources)
concatDelayError
fully supports backpressure.concatDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typesources
- the Observable sequence of Observablespublic static <T> Observable<T> concatDelayError(java.lang.Iterable<? extends Observable<? extends T>> sources)
Observable
sources are expected to honor backpressure as well. If the outer violates this, a
MissingBackpressureException
is signalled. If any of the inner Observable
s violates
this, it may throw an IllegalStateException
when an inner Observable
completes.concatDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typesources
- the Iterable sequence of Observablespublic static <T> Observable<T> concatDelayError(Observable<? extends T> t1, Observable<? extends T> t2)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.concatDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be concatenatedt2
- an Observable to be concatenatedpublic static <T> Observable<T> concatDelayError(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.concatDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be concatenatedt2
- an Observable to be concatenatedt3
- an Observable to be concatenatedpublic static <T> Observable<T> concatDelayError(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.concatDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be concatenatedt2
- an Observable to be concatenatedt3
- an Observable to be concatenatedt4
- an Observable to be concatenatedpublic static <T> Observable<T> concatDelayError(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.concatDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be concatenatedt2
- an Observable to be concatenatedt3
- an Observable to be concatenatedt4
- an Observable to be concatenatedt5
- an Observable to be concatenatedpublic static <T> Observable<T> concatDelayError(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5, Observable<? extends T> t6)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.concatDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be concatenatedt2
- an Observable to be concatenatedt3
- an Observable to be concatenatedt4
- an Observable to be concatenatedt5
- an Observable to be concatenatedt6
- an Observable to be concatenatedpublic static <T> Observable<T> concatDelayError(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5, Observable<? extends T> t6, Observable<? extends T> t7)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.concatDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be concatenatedt2
- an Observable to be concatenatedt3
- an Observable to be concatenatedt4
- an Observable to be concatenatedt5
- an Observable to be concatenatedt6
- an Observable to be concatenatedt7
- an Observable to be concatenatedpublic static <T> Observable<T> concatDelayError(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5, Observable<? extends T> t6, Observable<? extends T> t7, Observable<? extends T> t8)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.concatDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be concatenatedt2
- an Observable to be concatenatedt3
- an Observable to be concatenatedt4
- an Observable to be concatenatedt5
- an Observable to be concatenatedt6
- an Observable to be concatenatedt7
- an Observable to be concatenatedt8
- an Observable to be concatenatedpublic static <T> Observable<T> concatDelayError(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5, Observable<? extends T> t6, Observable<? extends T> t7, Observable<? extends T> t8, Observable<? extends T> t9)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.concatDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be concatenatedt2
- an Observable to be concatenatedt3
- an Observable to be concatenatedt4
- an Observable to be concatenatedt5
- an Observable to be concatenatedt6
- an Observable to be concatenatedt7
- an Observable to be concatenatedt8
- an Observable to be concatenatedt9
- an Observable to be concatenatedpublic static <T> Observable<T> defer(Func0<Observable<T>> observableFactory)
The defer Observer allows you to defer or delay emitting items from an Observable until such time as an
Observer subscribes to the Observable. This allows an Observer
to easily obtain updates or a
refreshed version of the sequence.
Observable
returned by the observableFactory
.defer
does not operate by default on a particular Scheduler
.T
- the type of the items emitted by the ObservableobservableFactory
- the Observable factory function to invoke for each Observer
that subscribes to the
resulting ObservableObserver
s' subscriptions trigger an invocation of the given
Observable factory functionpublic static <T> Observable<T> empty()
Observer
and immediately invokes its
onCompleted
method.
empty
does not operate by default on a particular Scheduler
.T
- the type of the items (ostensibly) emitted by the ObservableObserver
but immediately invokes the
Observer
's onCompleted
methodpublic static <T> Observable<T> error(java.lang.Throwable exception)
Observer
's onError
method when the
Observer subscribes to it.
error
does not operate by default on a particular Scheduler
.T
- the type of the items (ostensibly) emitted by the Observableexception
- the particular Throwable to pass to onError
Observer
's onError
method when
the Observer subscribes to itpublic static <T> Observable<T> from(java.util.concurrent.Future<? extends T> future)
Future
into an Observable.
You can convert any object that supports the Future
interface into an Observable that emits the
return value of the Future.get()
method of that object, by passing the object into the from
method.
Important note: This Observable is blocking; you cannot unsubscribe from it.
from
does not operate by default on a particular Scheduler
.T
- the type of object that the Future
returns, and also the type of item to be emitted by
the resulting Observablefuture
- the source Future
Future
public static <T> Observable<T> from(java.util.concurrent.Future<? extends T> future, long timeout, java.util.concurrent.TimeUnit unit)
Future
into an Observable, with a timeout on the Future.
You can convert any object that supports the Future
interface into an Observable that emits the
return value of the Future.get()
method of that object, by passing the object into the from
method.
Important note: This Observable is blocking; you cannot unsubscribe from it.
from
does not operate by default on a particular Scheduler
.T
- the type of object that the Future
returns, and also the type of item to be emitted by
the resulting Observablefuture
- the source Future
timeout
- the maximum time to wait before calling get
unit
- the TimeUnit
of the timeout
argumentFuture
public static <T> Observable<T> from(java.util.concurrent.Future<? extends T> future, Scheduler scheduler)
Future
, operating on a specified Scheduler
, into an Observable.
You can convert any object that supports the Future
interface into an Observable that emits the
return value of the Future.get()
method of that object, by passing the object into the from
method.
Scheduler
this operator will useT
- the type of object that the Future
returns, and also the type of item to be emitted by
the resulting Observablefuture
- the source Future
scheduler
- the Scheduler
to wait for the Future on. Use a Scheduler such as
Schedulers.io()
that can block and wait on the FutureFuture
public static <T> Observable<T> from(java.lang.Iterable<? extends T> iterable)
Iterable
sequence into an Observable that emits the items in the sequence.
iterable
on demand (i.e., when requested).from
does not operate by default on a particular Scheduler
.T
- the type of items in the Iterable
sequence and the type of items to be emitted by the
resulting Observableiterable
- the source Iterable
sequenceIterable
sequencepublic static <T> Observable<T> from(T[] array)
array
on demand (i.e., when requested).from
does not operate by default on a particular Scheduler
.T
- the type of items in the Array and the type of items to be emitted by the resulting Observablearray
- the source Arraypublic static <T> Observable<T> fromCallable(java.util.concurrent.Callable<? extends T> func)
This allows you to defer the execution of the function you specify until an observer subscribes to the Observable. That is to say, it makes the function "lazy."
fromCallable
does not operate by default on a particular Scheduler
.T
- the type of the item emitted by the Observablefunc
- a function, the execution of which should be deferred; fromCallable
will invoke this
function only when an observer subscribes to the Observable that fromCallable
returnsObserver
s' subscriptions trigger an invocation of the given functiondefer(Func0)
public static Observable<java.lang.Long> interval(long interval, java.util.concurrent.TimeUnit unit)
interval
operates by default on the computation
Scheduler
.interval
- interval size in time units (see below)unit
- time units to use for the interval sizepublic static Observable<java.lang.Long> interval(long interval, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
MissingBackpressureException
at some point in the chain.
Consumers should consider applying one of the onBackpressureXXX
operators as well.Scheduler
this operator will useinterval
- interval size in time units (see below)unit
- time units to use for the interval sizescheduler
- the Scheduler to use for scheduling the itemspublic static Observable<java.lang.Long> interval(long initialDelay, long period, java.util.concurrent.TimeUnit unit)
0L
after the initialDelay
and ever increasing numbers
after each period
of time thereafter.
MissingBackpressureException
at some point in the chain.
Consumers should consider applying one of the onBackpressureXXX
operators as well.interval
operates by default on the computation
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 both initialDelay
and period
initialDelay
and ever increasing numbers after
each period
of time thereafterpublic static Observable<java.lang.Long> interval(long initialDelay, long period, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
0L
after the initialDelay
and ever increasing numbers
after each period
of time thereafter, on a specified Scheduler
.
MissingBackpressureException
at some point in the chain.
Consumers should consider applying one of the onBackpressureXXX
operators as well.Scheduler
this operator will useinitialDelay
- 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 both initialDelay
and period
scheduler
- the Scheduler on which the waiting happens and items are emittedinitialDelay
and ever increasing numbers after
each period
of time thereafter, while running on the given Schedulerpublic static <T> Observable<T> just(T value)
To convert any object into an Observable that emits that object, pass that object into the just
method.
This is similar to the from(java.lang.Object[])
method, except that from
will convert
an Iterable
object into an Observable that emits each of the items in the Iterable, one at a
time, while the just
method converts an Iterable into an Observable that emits the entire
Iterable as a single item.
just
does not operate by default on a particular Scheduler
.T
- the type of that itemvalue
- the item to emitvalue
as a single item and then completespublic static <T> Observable<T> just(T t1, T t2)
just
does not operate by default on a particular Scheduler
.T
- the type of these itemst1
- first itemt2
- second itempublic static <T> Observable<T> just(T t1, T t2, T t3)
just
does not operate by default on a particular Scheduler
.T
- the type of these itemst1
- first itemt2
- second itemt3
- third itempublic static <T> Observable<T> just(T t1, T t2, T t3, T t4)
just
does not operate by default on a particular Scheduler
.T
- the type of these itemst1
- first itemt2
- second itemt3
- third itemt4
- fourth itempublic static <T> Observable<T> just(T t1, T t2, T t3, T t4, T t5)
just
does not operate by default on a particular Scheduler
.T
- the type of these itemst1
- first itemt2
- second itemt3
- third itemt4
- fourth itemt5
- fifth itempublic static <T> Observable<T> just(T t1, T t2, T t3, T t4, T t5, T t6)
just
does not operate by default on a particular Scheduler
.T
- the type of these itemst1
- first itemt2
- second itemt3
- third itemt4
- fourth itemt5
- fifth itemt6
- sixth itempublic static <T> Observable<T> just(T t1, T t2, T t3, T t4, T t5, T t6, T t7)
just
does not operate by default on a particular Scheduler
.T
- the type of these itemst1
- first itemt2
- second itemt3
- third itemt4
- fourth itemt5
- fifth itemt6
- sixth itemt7
- seventh itempublic static <T> Observable<T> just(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T t8)
just
does not operate by default on a particular Scheduler
.T
- the type of these itemst1
- first itemt2
- second itemt3
- third itemt4
- fourth itemt5
- fifth itemt6
- sixth itemt7
- seventh itemt8
- eighth itempublic static <T> Observable<T> just(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T t8, T t9)
just
does not operate by default on a particular Scheduler
.T
- the type of these itemst1
- first itemt2
- second itemt3
- third itemt4
- fourth itemt5
- fifth itemt6
- sixth itemt7
- seventh itemt8
- eighth itemt9
- ninth itempublic static <T> Observable<T> just(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T t8, T t9, T t10)
just
does not operate by default on a particular Scheduler
.T
- the type of these itemst1
- first itemt2
- second itemt3
- third itemt4
- fourth itemt5
- fifth itemt6
- sixth itemt7
- seventh itemt8
- eighth itemt9
- ninth itemt10
- tenth itempublic static <T> Observable<T> merge(java.lang.Iterable<? extends Observable<? extends T>> sequences)
You can combine the items emitted by multiple Observables so that they appear as a single Observable, by
using the merge
method.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.merge
does not operate by default on a particular Scheduler
.T
- the common element base typesequences
- the Iterable of Observablespublic static <T> Observable<T> merge(java.lang.Iterable<? extends Observable<? extends T>> sequences, int maxConcurrent)
You can combine the items emitted by multiple Observables so that they appear as a single Observable, by
using the merge
method.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.merge
does not operate by default on a particular Scheduler
.T
- the common element base typesequences
- the Iterable of ObservablesmaxConcurrent
- the maximum number of Observables that may be subscribed to concurrentlyjava.lang.IllegalArgumentException
- if maxConcurrent
is less than or equal to 0public static <T> Observable<T> merge(Observable<? extends Observable<? extends T>> source)
You can combine the items emitted by multiple Observables so that they appear as a single Observable, by
using the merge
method.
Observable
is consumed
in unbounded mode (i.e., no backpressure is applied to it). The inner Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.merge
does not operate by default on a particular Scheduler
.T
- the common element base typesource
- an Observable that emits Observablessource
Observablepublic static <T> Observable<T> merge(Observable<? extends Observable<? extends T>> source, int maxConcurrent)
You can combine the items emitted by multiple Observables so that they appear as a single Observable, by
using the merge
method.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.merge
does not operate by default on a particular Scheduler
.T
- the common element base typesource
- an Observable that emits ObservablesmaxConcurrent
- the maximum number of Observables that may be subscribed to concurrentlysource
Observablejava.lang.IllegalArgumentException
- if maxConcurrent
is less than or equal to 0public static <T> Observable<T> merge(Observable<? extends T> t1, Observable<? extends T> t2)
You can combine items emitted by multiple Observables so that they appear as a single Observable, by
using the merge
method.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.merge
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be mergedt2
- an Observable to be mergedpublic static <T> Observable<T> merge(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3)
You can combine items emitted by multiple Observables so that they appear as a single Observable, by
using the merge
method.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.merge
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be mergedt2
- an Observable to be mergedt3
- an Observable to be mergedpublic static <T> Observable<T> merge(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4)
You can combine items emitted by multiple Observables so that they appear as a single Observable, by
using the merge
method.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.merge
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be mergedt2
- an Observable to be mergedt3
- an Observable to be mergedt4
- an Observable to be mergedpublic static <T> Observable<T> merge(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5)
You can combine items emitted by multiple Observables so that they appear as a single Observable, by
using the merge
method.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.merge
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be mergedt2
- an Observable to be mergedt3
- an Observable to be mergedt4
- an Observable to be mergedt5
- an Observable to be mergedpublic static <T> Observable<T> merge(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5, Observable<? extends T> t6)
You can combine items emitted by multiple Observables so that they appear as a single Observable, by
using the merge
method.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.merge
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be mergedt2
- an Observable to be mergedt3
- an Observable to be mergedt4
- an Observable to be mergedt5
- an Observable to be mergedt6
- an Observable to be mergedpublic static <T> Observable<T> merge(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5, Observable<? extends T> t6, Observable<? extends T> t7)
You can combine items emitted by multiple Observables so that they appear as a single Observable, by
using the merge
method.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.merge
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be mergedt2
- an Observable to be mergedt3
- an Observable to be mergedt4
- an Observable to be mergedt5
- an Observable to be mergedt6
- an Observable to be mergedt7
- an Observable to be mergedpublic static <T> Observable<T> merge(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5, Observable<? extends T> t6, Observable<? extends T> t7, Observable<? extends T> t8)
You can combine items emitted by multiple Observables so that they appear as a single Observable, by
using the merge
method.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.merge
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be mergedt2
- an Observable to be mergedt3
- an Observable to be mergedt4
- an Observable to be mergedt5
- an Observable to be mergedt6
- an Observable to be mergedt7
- an Observable to be mergedt8
- an Observable to be mergedpublic static <T> Observable<T> merge(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5, Observable<? extends T> t6, Observable<? extends T> t7, Observable<? extends T> t8, Observable<? extends T> t9)
You can combine items emitted by multiple Observables so that they appear as a single Observable, by
using the merge
method.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.merge
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be mergedt2
- an Observable to be mergedt3
- an Observable to be mergedt4
- an Observable to be mergedt5
- an Observable to be mergedt6
- an Observable to be mergedt7
- an Observable to be mergedt8
- an Observable to be mergedt9
- an Observable to be mergedpublic static <T> Observable<T> merge(Observable<? extends T>[] sequences)
You can combine items emitted by multiple Observables so that they appear as a single Observable, by
using the merge
method.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.merge
does not operate by default on a particular Scheduler
.T
- the common element base typesequences
- the Array of Observablespublic static <T> Observable<T> merge(Observable<? extends T>[] sequences, int maxConcurrent)
You can combine items emitted by multiple Observables so that they appear as a single Observable, by
using the merge
method.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.merge
does not operate by default on a particular Scheduler
.T
- the common element base typesequences
- the Array of ObservablesmaxConcurrent
- the maximum number of Observables that may be subscribed to concurrentlypublic static <T> Observable<T> mergeDelayError(Observable<? extends Observable<? extends T>> source)
This behaves like merge(Observable)
except that if any of the merged Observables notify of an
error via onError
, mergeDelayError
will refrain from propagating that
error notification until all of the merged Observables have finished emitting items.
Even if multiple merged Observables send onError
notifications, mergeDelayError
will only
invoke the onError
method of its Observers once.
Observable
is consumed
in unbounded mode (i.e., no backpressure is applied to it). The inner Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.mergeDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typesource
- an Observable that emits Observablessource
Observablepublic static <T> Observable<T> mergeDelayError(Observable<? extends Observable<? extends T>> source, int maxConcurrent)
This behaves like merge(Observable)
except that if any of the merged Observables notify of an
error via onError
, mergeDelayError
will refrain from propagating that
error notification until all of the merged Observables have finished emitting items.
Even if multiple merged Observables send onError
notifications, mergeDelayError
will only
invoke the onError
method of its Observers once.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.mergeDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typesource
- an Observable that emits ObservablesmaxConcurrent
- the maximum number of Observables that may be subscribed to concurrentlysource
Observablepublic static <T> Observable<T> mergeDelayError(java.lang.Iterable<? extends Observable<? extends T>> sequences)
This behaves like merge(Observable)
except that if any of the merged Observables notify of an
error via onError
, mergeDelayError
will refrain from propagating that
error notification until all of the merged Observables have finished emitting items.
Even if multiple merged Observables send onError
notifications, mergeDelayError
will only
invoke the onError
method of its Observers once.
mergeDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typesequences
- the Iterable of Observablespublic static <T> Observable<T> mergeDelayError(java.lang.Iterable<? extends Observable<? extends T>> sequences, int maxConcurrent)
This behaves like merge(Observable)
except that if any of the merged Observables notify of an
error via onError
, mergeDelayError
will refrain from propagating that
error notification until all of the merged Observables have finished emitting items.
Even if multiple merged Observables send onError
notifications, mergeDelayError
will only
invoke the onError
method of its Observers once.
mergeDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typesequences
- the Iterable of ObservablesmaxConcurrent
- the maximum number of Observables that may be subscribed to concurrentlypublic static <T> Observable<T> mergeDelayError(Observable<? extends T> t1, Observable<? extends T> t2)
This behaves like merge(Observable, Observable)
except that if any of the merged Observables
notify of an error via onError
, mergeDelayError
will refrain from
propagating that error notification until all of the merged Observables have finished emitting items.
Even if both merged Observables send onError
notifications, mergeDelayError
will only
invoke the onError
method of its Observers once.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.mergeDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be mergedt2
- an Observable to be mergedpublic static <T> Observable<T> mergeDelayError(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3)
This behaves like merge(Observable, Observable, Observable)
except that if any of the merged
Observables notify of an error via onError
, mergeDelayError
will refrain
from propagating that error notification until all of the merged Observables have finished emitting
items.
Even if multiple merged Observables send onError
notifications, mergeDelayError
will only
invoke the onError
method of its Observers once.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.mergeDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be mergedt2
- an Observable to be mergedt3
- an Observable to be mergedpublic static <T> Observable<T> mergeDelayError(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4)
This behaves like merge(Observable, Observable, Observable, Observable)
except that if any of
the merged Observables notify of an error via onError
, mergeDelayError
will refrain from propagating that error notification until all of the merged Observables have finished
emitting items.
Even if multiple merged Observables send onError
notifications, mergeDelayError
will only
invoke the onError
method of its Observers once.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.mergeDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be mergedt2
- an Observable to be mergedt3
- an Observable to be mergedt4
- an Observable to be mergedpublic static <T> Observable<T> mergeDelayError(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5)
This behaves like merge(Observable, Observable, Observable, Observable, Observable)
except that
if any of the merged Observables notify of an error via onError
,
mergeDelayError
will refrain from propagating that error notification until all of the merged
Observables have finished emitting items.
Even if multiple merged Observables send onError
notifications, mergeDelayError
will only
invoke the onError
method of its Observers once.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.mergeDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be mergedt2
- an Observable to be mergedt3
- an Observable to be mergedt4
- an Observable to be mergedt5
- an Observable to be mergedpublic static <T> Observable<T> mergeDelayError(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5, Observable<? extends T> t6)
This behaves like merge(Observable, Observable, Observable, Observable, Observable, Observable)
except that if any of the merged Observables notify of an error via onError
,
mergeDelayError
will refrain from propagating that error notification until all of the merged
Observables have finished emitting items.
Even if multiple merged Observables send onError
notifications, mergeDelayError
will only
invoke the onError
method of its Observers once.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.mergeDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be mergedt2
- an Observable to be mergedt3
- an Observable to be mergedt4
- an Observable to be mergedt5
- an Observable to be mergedt6
- an Observable to be mergedpublic static <T> Observable<T> mergeDelayError(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5, Observable<? extends T> t6, Observable<? extends T> t7)
This behaves like
merge(Observable, Observable, Observable, Observable, Observable, Observable, Observable)
except that if any of the merged Observables notify of an error via onError
,
mergeDelayError
will refrain from propagating that error notification until all of the merged
Observables have finished emitting items.
Even if multiple merged Observables send onError
notifications, mergeDelayError
will only
invoke the onError
method of its Observers once.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.mergeDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be mergedt2
- an Observable to be mergedt3
- an Observable to be mergedt4
- an Observable to be mergedt5
- an Observable to be mergedt6
- an Observable to be mergedt7
- an Observable to be mergedpublic static <T> Observable<T> mergeDelayError(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5, Observable<? extends T> t6, Observable<? extends T> t7, Observable<? extends T> t8)
This behaves like merge(Observable, Observable, Observable, Observable, Observable, Observable, Observable, Observable)
except that if any of the merged Observables notify of an error via onError
,
mergeDelayError
will refrain from propagating that error notification until all of the merged
Observables have finished emitting items.
Even if multiple merged Observables send onError
notifications, mergeDelayError
will only
invoke the onError
method of its Observers once.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.mergeDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be mergedt2
- an Observable to be mergedt3
- an Observable to be mergedt4
- an Observable to be mergedt5
- an Observable to be mergedt6
- an Observable to be mergedt7
- an Observable to be mergedt8
- an Observable to be mergedpublic static <T> Observable<T> mergeDelayError(Observable<? extends T> t1, Observable<? extends T> t2, Observable<? extends T> t3, Observable<? extends T> t4, Observable<? extends T> t5, Observable<? extends T> t6, Observable<? extends T> t7, Observable<? extends T> t8, Observable<? extends T> t9)
This behaves like merge(Observable, Observable, Observable, Observable, Observable, Observable, Observable, Observable, Observable)
except that if any of the merged Observables notify of an error via onError
,
mergeDelayError
will refrain from propagating that error notification until all of the merged
Observables have finished emitting items.
Even if multiple merged Observables send onError
notifications, mergeDelayError
will only
invoke the onError
method of its Observers once.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.mergeDelayError
does not operate by default on a particular Scheduler
.T
- the common element base typet1
- an Observable to be mergedt2
- an Observable to be mergedt3
- an Observable to be mergedt4
- an Observable to be mergedt5
- an Observable to be mergedt6
- an Observable to be mergedt7
- an Observable to be mergedt8
- an Observable to be mergedt9
- an Observable to be mergedpublic final Observable<Observable<T>> nest()
Observable<T>
into an Observable<Observable<T>>
that emits the
source Observable as its single emission.
nest
does not operate by default on a particular Scheduler
.public static <T> Observable<T> never()
Observer
.
This Observable is useful primarily for testing purposes.
never
does not operate by default on a particular Scheduler
.T
- the type of items (not) emitted by the ObservableObserver
public static Observable<java.lang.Integer> range(int start, int count)
range
does not operate by default on a particular Scheduler
.start
- the value of the first Integer in the sequencecount
- the number of sequential Integers to generatejava.lang.IllegalArgumentException
- if count
is less than zero, or if start
+ count
− 1 exceeds
Integer.MAX_VALUE
public static Observable<java.lang.Integer> range(int start, int count, Scheduler scheduler)
Scheduler
this operator will usestart
- the value of the first Integer in the sequencecount
- the number of sequential Integers to generatescheduler
- the Scheduler to run the generator loop onpublic static <T> Observable<java.lang.Boolean> sequenceEqual(Observable<? extends T> first, Observable<? extends T> second)
sequenceEqual
does not operate by default on a particular Scheduler
.T
- the type of items emitted by each Observablefirst
- the first Observable to comparesecond
- the second Observable to comparepublic static <T> Observable<java.lang.Boolean> sequenceEqual(Observable<? extends T> first, Observable<? extends T> second, Func2<? super T,? super T,java.lang.Boolean> equality)
Observable
s are expected to honor
backpressure; if violated, the operator signals a MissingBackpressureException
.sequenceEqual
does not operate by default on a particular Scheduler
.T
- the type of items emitted by each Observablefirst
- the first Observable to comparesecond
- the second Observable to compareequality
- a function used to compare items emitted by each Observablepublic static <T> Observable<T> switchOnNext(Observable<? extends Observable<? extends T>> sequenceOfSequences)
switchOnNext
subscribes to an Observable that emits Observables. Each time it observes one of
these emitted Observables, the Observable returned by switchOnNext
begins emitting the items
emitted by that Observable. When a new Observable is emitted, switchOnNext
stops emitting items
from the earlier-emitted Observable and begins emitting items from the new one.
The resulting Observable completes if both the outer Observable and the last inner Observable, if any, complete. If the outer Observable signals an onError, the inner Observable is unsubscribed and the error delivered in-sequence.
Observable
is consumed in an
unbounded manner (i.e., without backpressure) and the inner Observable
s are expected to honor
backpressure but it is not enforced; the operator won't signal a MissingBackpressureException
but the violation may lead to OutOfMemoryError
due to internal buffer bloat.switchOnNext
does not operate by default on a particular Scheduler
.T
- the item typesequenceOfSequences
- the source Observable that emits Observablespublic static <T> Observable<T> switchOnNextDelayError(Observable<? extends Observable<? extends T>> sequenceOfSequences)
switchOnNext
subscribes to an Observable that emits Observables. Each time it observes one of
these emitted Observables, the Observable returned by switchOnNext
begins emitting the items
emitted by that Observable. When a new Observable is emitted, switchOnNext
stops emitting items
from the earlier-emitted Observable and begins emitting items from the new one.
The resulting Observable completes if both the main Observable and the last inner Observable, if any, complete. If the main Observable signals an onError, the termination of the last inner Observable will emit that error as is or wrapped into a CompositeException along with the other possible errors the former inner Observables signalled.
Observable
is consumed in an
unbounded manner (i.e., without backpressure) and the inner Observable
s are expected to honor
backpressure but it is not enforced; the operator won't signal a MissingBackpressureException
but the violation may lead to OutOfMemoryError
due to internal buffer bloat.switchOnNext
does not operate by default on a particular Scheduler
.T
- the item typesequenceOfSequences
- the source Observable that emits Observables@Deprecated public static Observable<java.lang.Long> timer(long initialDelay, long period, java.util.concurrent.TimeUnit unit)
interval(long, long, TimeUnit)
instead0L
after the initialDelay
and ever increasing numbers
after each period
of time thereafter.
onBackpressureDrop(rx.functions.Action1<? super T>)
.timer
operates by default on the computation
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 both initialDelay
and period
initialDelay
and ever increasing numbers after
each period
of time thereafter@Deprecated public static Observable<java.lang.Long> timer(long initialDelay, long period, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
interval(long, long, TimeUnit, Scheduler)
instead0L
after the initialDelay
and ever increasing numbers
after each period
of time thereafter, on a specified Scheduler
.
onBackpressureDrop(rx.functions.Action1<? super T>)
.Scheduler
this operator will useinitialDelay
- 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 both initialDelay
and period
scheduler
- the Scheduler on which the waiting happens and items are emittedinitialDelay
and ever increasing numbers after
each period
of time thereafter, while running on the given Schedulerpublic static Observable<java.lang.Long> timer(long delay, java.util.concurrent.TimeUnit unit)
0L
after a specified delay, and then completes.
onBackpressureDrop(rx.functions.Action1<? super T>)
.timer
operates by default on the computation
Scheduler
.delay
- the initial delay before emitting a single 0L
unit
- time units to use for delay
public static Observable<java.lang.Long> timer(long delay, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
0L
after a specified delay, on a specified Scheduler, and then
completes.
onBackpressureDrop(rx.functions.Action1<? super T>)
.Scheduler
this operator will usedelay
- the initial delay before emitting a single 0Lunit
- time units to use for delay
scheduler
- the Scheduler
to use for scheduling the itempublic static <T,Resource> Observable<T> using(Func0<Resource> resourceFactory, Func1<? super Resource,? extends Observable<? extends T>> observableFactory, Action1<? super Resource> disposeAction)
resourceFactory
.using
does not operate by default on a particular Scheduler
.T
- the element type of the generated ObservableResource
- the type of the resource associated with the output sequenceresourceFactory
- the factory function to create a resource object that depends on the ObservableobservableFactory
- the factory function to create an ObservabledisposeAction
- the function that will dispose of the resourcepublic static <T,Resource> Observable<T> using(Func0<Resource> resourceFactory, Func1<? super Resource,? extends Observable<? extends T>> observableFactory, Action1<? super Resource> disposeAction, boolean disposeEagerly)
disposeEagerly
to true
and unsubscription does not occur
before termination. Otherwise resource disposal will occur on unsubscription. Eager disposal is
particularly appropriate for a synchronous Observable that reuses resources. disposeAction
will
only be called once per subscription.
resourceFactory
.using
does not operate by default on a particular Scheduler
.T
- the element type of the generated ObservableResource
- the type of the resource associated with the output sequenceresourceFactory
- the factory function to create a resource object that depends on the ObservableobservableFactory
- the factory function to create an ObservabledisposeAction
- the function that will dispose of the resourcedisposeEagerly
- if true
then disposal will happen either on unsubscription or just before emission of
a terminal event (onComplete
or onError
).public static <R> Observable<R> zip(java.lang.Iterable<? extends Observable<?>> ws, FuncN<? extends R> zipFunction)
zip
applies this function in strict sequence, so the first item emitted by the new Observable
will be the result of the function applied to the first item emitted by each of the source Observables;
the second item emitted by the new Observable will be the result of the function applied to the second
item emitted by each of those Observables; and so forth.
The resulting Observable<R>
returned from zip
will invoke onNext
as many times as
the number of onNext
invocations of the source Observable 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 unsubscribing the other sources. Therefore, it
is possible those other sources will never be able to run to completion (and thus not calling
doOnCompleted()
). 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 unsubscribe B immediately. For example:
zip(Arrays.asList(range(1, 5).doOnCompleted(action1), range(6, 5).doOnCompleted(action2)), (a) -> a)
action1
will be called but action2
won't.
doOnUnsubscribed()
as well or use using()
to do cleanup in case of completion
or unsubscription.
interval(long, TimeUnit)
may result in MissingBackpressureException, use
one of the onBackpressureX
to handle similar, backpressure-ignoring sources.zip
does not operate by default on a particular Scheduler
.R
- the zipped result typews
- an Iterable of source ObservableszipFunction
- a function that, when applied to an item emitted by each of the source Observables, results in
an item that will be emitted by the resulting Observablepublic static <R> Observable<R> zip(Observable<?>[] ws, FuncN<? extends R> zipFunction)
zip
applies this function in strict sequence, so the first item emitted by the new Observable
will be the result of the function applied to the first item emitted by each of the source Observables;
the second item emitted by the new Observable will be the result of the function applied to the second
item emitted by each of those Observables; and so forth.
The resulting Observable<R>
returned from zip
will invoke onNext
as many times as
the number of onNext
invocations of the source Observable 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 unsubscribing the other sources. Therefore, it
is possible those other sources will never be able to run to completion (and thus not calling
doOnCompleted()
). 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 unsubscribe B immediately. For example:
zip(new Observable[]{range(1, 5).doOnCompleted(action1), range(6, 5).doOnCompleted(action2)}, (a) ->
a)
action1
will be called but action2
won't.
doOnUnsubscribed()
as well or use using()
to do cleanup in case of completion
or unsubscription.
interval(long, TimeUnit)
may result in MissingBackpressureException, use
one of the onBackpressureX
to handle similar, backpressure-ignoring sources.zip
does not operate by default on a particular Scheduler
.R
- the result typews
- an array of source ObservableszipFunction
- a function that, when applied to an item emitted by each of the source Observables, results in
an item that will be emitted by the resulting Observablepublic static <R> Observable<R> zip(Observable<? extends Observable<?>> ws, FuncN<? extends R> zipFunction)
zip
applies this function in strict sequence, so the first item emitted by the new Observable
will be the result of the function applied to the first item emitted by each of the Observables emitted
by the source Observable; the second item emitted by the new Observable will be the result of the
function applied to the second item emitted by each of those Observables; and so forth.
The resulting Observable<R>
returned from zip
will invoke onNext
as many times as
the number of onNext
invocations of the source Observable 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 unsubscribing the other sources. Therefore, it
is possible those other sources will never be able to run to completion (and thus not calling
doOnCompleted()
). 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 unsubscribe B immediately. For example:
zip(just(range(1, 5).doOnCompleted(action1), range(6, 5).doOnCompleted(action2)), (a) -> a)
action1
will be called but action2
won't.
doOnUnsubscribed()
as well or use using()
to do cleanup in case of completion
or unsubscription.
interval(long, TimeUnit)
may result in MissingBackpressureException, use
one of the onBackpressureX
to handle similar, backpressure-ignoring sources.zip
does not operate by default on a particular Scheduler
.R
- the zipped result typews
- an Observable of source ObservableszipFunction
- a function that, when applied to an item emitted by each of the Observables emitted by
ws
, results in an item that will be emitted by the resulting Observablepublic static <T1,T2,R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Func2<? super T1,? super T2,? extends R> zipFunction)
zip
applies this function in strict sequence, so the first item emitted by the new Observable
will be the result of the function applied to the first item emitted by o1
and the first item
emitted by o2
; the second item emitted by the new Observable will be the result of the function
applied to the second item emitted by o1
and the second item emitted by o2
; and so forth.
The resulting Observable<R>
returned from zip
will invoke onNext
as many times as the number of onNext
invocations of the source Observable 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 unsubscribing the other sources. Therefore, it
is possible those other sources will never be able to run to completion (and thus not calling
doOnCompleted()
). 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 unsubscribe B immediately. For example:
zip(range(1, 5).doOnCompleted(action1), range(6, 5).doOnCompleted(action2), (a, b) -> a + b)
action1
will be called but action2
won't.
doOnUnsubscribed()
as well or use using()
to do cleanup in case of completion
or unsubscription.
interval(long, TimeUnit)
may result in MissingBackpressureException, use
one of the onBackpressureX
to handle similar, backpressure-ignoring sources.zip
does not operate by default on a particular Scheduler
.T1
- the value type of the first sourceT2
- the value type of the second sourceR
- the zipped result typeo1
- the first source Observableo2
- a second source ObservablezipFunction
- a function that, when applied to an item emitted by each of the source Observables, results
in an item that will be emitted by the resulting Observablepublic static <T1,T2,T3,R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Func3<? super T1,? super T2,? super T3,? extends R> zipFunction)
zip
applies this function in strict sequence, so the first item emitted by the new Observable
will be the result of the function applied to the first item emitted by o1
, the first item
emitted by o2
, and the first item emitted by o3
; the second item emitted by the new
Observable will be the result of the function applied to the second item emitted by o1
, the
second item emitted by o2
, and the second item emitted by o3
; and so forth.
The resulting Observable<R>
returned from zip
will invoke onNext
as many times as the number of onNext
invocations of the source Observable 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 unsubscribing the other sources. Therefore, it
is possible those other sources will never be able to run to completion (and thus not calling
doOnCompleted()
). 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 unsubscribe B immediately. For example:
zip(range(1, 5).doOnCompleted(action1), range(6, 5).doOnCompleted(action2), ..., (a, b, c) -> a + b)
action1
will be called but action2
won't.
doOnUnsubscribed()
as well or use using()
to do cleanup in case of completion
or unsubscription.
interval(long, TimeUnit)
may result in MissingBackpressureException, use
one of the onBackpressureX
to handle similar, backpressure-ignoring sources.zip
does not operate by default on a particular Scheduler
.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 typeo1
- the first source Observableo2
- a second source Observableo3
- a third source ObservablezipFunction
- a function that, when applied to an item emitted by each of the source Observables, results in
an item that will be emitted by the resulting Observablepublic static <T1,T2,T3,T4,R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Func4<? super T1,? super T2,? super T3,? super T4,? extends R> zipFunction)
zip
applies this function in strict sequence, so the first item emitted by the new Observable
will be the result of the function applied to the first item emitted by o1
, the first item
emitted by o2
, the first item emitted by o3
, and the first item emitted by 04
;
the second item emitted by the new Observable will be the result of the function applied to the second
item emitted by each of those Observables; and so forth.
The resulting Observable<R>
returned from zip
will invoke onNext
as many times as the number of onNext
invocations of the source Observable 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 unsubscribing the other sources. Therefore, it
is possible those other sources will never be able to run to completion (and thus not calling
doOnCompleted()
). 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 unsubscribe B immediately. For example:
zip(range(1, 5).doOnCompleted(action1), range(6, 5).doOnCompleted(action2), ..., (a, b, c, d) -> a + b)
action1
will be called but action2
won't.
doOnUnsubscribed()
as well or use using()
to do cleanup in case of completion
or unsubscription.
interval(long, TimeUnit)
may result in MissingBackpressureException, use
one of the onBackpressureX
to handle similar, backpressure-ignoring sources.zip
does not operate by default on a particular Scheduler
.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 typeo1
- the first source Observableo2
- a second source Observableo3
- a third source Observableo4
- a fourth source ObservablezipFunction
- a function that, when applied to an item emitted by each of the source Observables, results in
an item that will be emitted by the resulting Observablepublic static <T1,T2,T3,T4,T5,R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Func5<? super T1,? super T2,? super T3,? super T4,? super T5,? extends R> zipFunction)
zip
applies this function in strict sequence, so the first item emitted by the new Observable
will be the result of the function applied to the first item emitted by o1
, the first item
emitted by o2
, the first item emitted by o3
, the first item emitted by o4
, and
the first item emitted by o5
; the second item emitted by the new Observable will be the result of
the function applied to the second item emitted by each of those Observables; and so forth.
The resulting Observable<R>
returned from zip
will invoke onNext
as many times as the number of onNext
invocations of the source Observable 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 unsubscribing the other sources. Therefore, it
is possible those other sources will never be able to run to completion (and thus not calling
doOnCompleted()
). 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 unsubscribe B immediately. For example:
zip(range(1, 5).doOnCompleted(action1), range(6, 5).doOnCompleted(action2), ..., (a, b, c, d, e) -> a + b)
action1
will be called but action2
won't.
doOnUnsubscribed()
as well or use using()
to do cleanup in case of completion
or unsubscription.
interval(long, TimeUnit)
may result in MissingBackpressureException, use
one of the onBackpressureX
to handle similar, backpressure-ignoring sources.zip
does not operate by default on a particular Scheduler
.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 typeo1
- the first source Observableo2
- a second source Observableo3
- a third source Observableo4
- a fourth source Observableo5
- a fifth source ObservablezipFunction
- a function that, when applied to an item emitted by each of the source Observables, results in
an item that will be emitted by the resulting Observablepublic static <T1,T2,T3,T4,T5,T6,R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Observable<? extends T6> o6, Func6<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? extends R> zipFunction)
zip
applies this function in strict sequence, so the first item emitted by the new Observable
will be the result of the function applied to the first item emitted by each source Observable, the
second item emitted by the new Observable will be the result of the function applied to the second item
emitted by each of those Observables, and so forth.
The resulting Observable<R>
returned from zip
will invoke onNext
as many times as the number of onNext
invocations of the source Observable 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 unsubscribing the other sources. Therefore, it
is possible those other sources will never be able to run to completion (and thus not calling
doOnCompleted()
). 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 unsubscribe B immediately. For example:
zip(range(1, 5).doOnCompleted(action1), range(6, 5).doOnCompleted(action2), ..., (a, b, c, d, e, f) -> a + b)
action1
will be called but action2
won't.
doOnUnsubscribed()
as well or use using()
to do cleanup in case of completion
or unsubscription.
interval(long, TimeUnit)
may result in MissingBackpressureException, use
one of the onBackpressureX
to handle similar, backpressure-ignoring sources.zip
does not operate by default on a particular Scheduler
.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 typeo1
- the first source Observableo2
- a second source Observableo3
- a third source Observableo4
- a fourth source Observableo5
- a fifth source Observableo6
- a sixth source ObservablezipFunction
- a function that, when applied to an item emitted by each of the source Observables, results in
an item that will be emitted by the resulting Observablepublic static <T1,T2,T3,T4,T5,T6,T7,R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Observable<? extends T6> o6, Observable<? extends T7> o7, Func7<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? extends R> zipFunction)
zip
applies this function in strict sequence, so the first item emitted by the new Observable
will be the result of the function applied to the first item emitted by each source Observable, the
second item emitted by the new Observable will be the result of the function applied to the second item
emitted by each of those Observables, and so forth.
The resulting Observable<R>
returned from zip
will invoke onNext
as many times as the number of onNext
invocations of the source Observable 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 unsubscribing the other sources. Therefore, it
is possible those other sources will never be able to run to completion (and thus not calling
doOnCompleted()
). 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 unsubscribe B immediately. For example:
zip(range(1, 5).doOnCompleted(action1), range(6, 5).doOnCompleted(action2), ..., (a, b, c, d, e, f, g) -> a + b)
action1
will be called but action2
won't.
doOnUnsubscribed()
as well or use using()
to do cleanup in case of completion
or unsubscription.
interval(long, TimeUnit)
may result in MissingBackpressureException, use
one of the onBackpressureX
to handle similar, backpressure-ignoring sources.zip
does not operate by default on a particular Scheduler
.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 typeo1
- the first source Observableo2
- a second source Observableo3
- a third source Observableo4
- a fourth source Observableo5
- a fifth source Observableo6
- a sixth source Observableo7
- a seventh source ObservablezipFunction
- a function that, when applied to an item emitted by each of the source Observables, results in
an item that will be emitted by the resulting Observablepublic static <T1,T2,T3,T4,T5,T6,T7,T8,R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Observable<? extends T6> o6, Observable<? extends T7> o7, Observable<? extends T8> o8, Func8<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? extends R> zipFunction)
zip
applies this function in strict sequence, so the first item emitted by the new Observable
will be the result of the function applied to the first item emitted by each source Observable, the
second item emitted by the new Observable will be the result of the function applied to the second item
emitted by each of those Observables, and so forth.
The resulting Observable<R>
returned from zip
will invoke onNext
as many times as the number of onNext
invocations of the source Observable 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 unsubscribing the other sources. Therefore, it
is possible those other sources will never be able to run to completion (and thus not calling
doOnCompleted()
). 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 unsubscribe B immediately. For example:
zip(range(1, 5).doOnCompleted(action1), range(6, 5).doOnCompleted(action2), ..., (a, b, c, d, e, f, g, h) -> a + b)
action1
will be called but action2
won't.
doOnUnsubscribed()
as well or use using()
to do cleanup in case of completion
or unsubscription.
interval(long, TimeUnit)
may result in MissingBackpressureException, use
one of the onBackpressureX
to handle similar, backpressure-ignoring sources.zip
does not operate by default on a particular Scheduler
.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 typeo1
- the first source Observableo2
- a second source Observableo3
- a third source Observableo4
- a fourth source Observableo5
- a fifth source Observableo6
- a sixth source Observableo7
- a seventh source Observableo8
- an eighth source ObservablezipFunction
- a function that, when applied to an item emitted by each of the source Observables, results in
an item that will be emitted by the resulting Observablepublic static <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Observable<? extends T4> o4, Observable<? extends T5> o5, Observable<? extends T6> o6, Observable<? extends T7> o7, Observable<? extends T8> o8, Observable<? extends T9> o9, Func9<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? super T9,? extends R> zipFunction)
zip
applies this function in strict sequence, so the first item emitted by the new Observable
will be the result of the function applied to the first item emitted by each source Observable, the
second item emitted by the new Observable will be the result of the function applied to the second item
emitted by each of those Observables, and so forth.
The resulting Observable<R>
returned from zip
will invoke onNext
as many times as the number of onNext
invocations of the source Observable 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 unsubscribing the other sources. Therefore, it
is possible those other sources will never be able to run to completion (and thus not calling
doOnCompleted()
). 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 unsubscribe B immediately. For example:
zip(range(1, 5).doOnCompleted(action1), range(6, 5).doOnCompleted(action2), ..., (a, b, c, d, e, f, g, h, i) -> a + b)
action1
will be called but action2
won't.
doOnUnsubscribed()
as well or use using()
to do cleanup in case of completion
or unsubscription.
interval(long, TimeUnit)
may result in MissingBackpressureException, use
one of the onBackpressureX
to handle similar, backpressure-ignoring sources.zip
does not operate by default on a particular Scheduler
.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 typeo1
- the first source Observableo2
- a second source Observableo3
- a third source Observableo4
- a fourth source Observableo5
- a fifth source Observableo6
- a sixth source Observableo7
- a seventh source Observableo8
- an eighth source Observableo9
- a ninth source ObservablezipFunction
- a function that, when applied to an item emitted by each of the source Observables, results in
an item that will be emitted by the resulting Observablepublic final Observable<java.lang.Boolean> all(Func1<? super T,java.lang.Boolean> predicate)
Observable
in an unbounded
manner (i.e., without applying backpressure).all
does not operate by default on a particular Scheduler
.predicate
- a function that evaluates an item and returns a Booleantrue
if all items emitted by the source Observable satisfy the
predicate; otherwise, false
public final Observable<T> ambWith(Observable<? extends T> t1)
Observable
's backpressure behavior.amb
does not operate by default on a particular Scheduler
.t1
- an Observable competing to react firstpublic final Observable<T> asObservable()
Observable
's backpressure behavior.asObservable
does not operate by default on a particular Scheduler
.public final <TClosing> Observable<java.util.List<T>> buffer(Func0<? extends Observable<? extends TClosing>> bufferClosingSelector)
bufferClosingSelector
emits an item.
Long.MAX_VALUE
upstream and does not obey downstream requests.buffer
does not operate by default on a particular Scheduler
.TClosing
- the value type of the boundary-providing ObservablebufferClosingSelector
- a Func0
that produces an Observable that governs the boundary between buffers.
Whenever the source Observable
emits an item, buffer
emits the current buffer and
begins to fill a new onebufferClosingSelector
argument emits an itempublic final Observable<java.util.List<T>> buffer(int count)
count
items. When the source
Observable completes or encounters an error, the resulting Observable emits the current buffer and
propagates the notification from the source Observable.
Observable
to honor it as
well, although not enforced; violation may lead to MissingBackpressureException
somewhere
downstream.buffer
does not operate by default on a particular Scheduler
.count
- the maximum number of items in each buffer before it should be emittedcount
items from the source Observablepublic final Observable<java.util.List<T>> buffer(int count, int skip)
skip
items, each containing count
items. When the source
Observable completes or encounters an error, the resulting Observable emits the current buffer and
propagates the notification from the source Observable.
Observable
to honor it as
well, although not enforced; violation may lead to MissingBackpressureException
somewhere
downstream.buffer
does not operate by default on a particular Scheduler
.count
- the maximum size of each buffer before it should be emittedskip
- how many items emitted by the source Observable should be skipped before starting a new
buffer. Note that when skip
and count
are equal, this is the same operation as
buffer(int)
.skip
item from the source Observable and
containing at most count
itemspublic final Observable<java.util.List<T>> buffer(long timespan, long timeshift, java.util.concurrent.TimeUnit unit)
timeshift
argument. It emits
each buffer after a fixed timespan, specified by the timespan
argument. When the source
Observable completes or encounters an error, the resulting Observable emits the current buffer and
propagates the notification from the source Observable.
Long.MAX_VALUE
upstream and does not obey downstream requests.buffer
operates by default on the computation
Scheduler
.timespan
- the period of time each buffer collects items before it is emittedtimeshift
- the period of time after which a new buffer will be createdunit
- the unit of time that applies to the timespan
and timeshift
argumentspublic final Observable<java.util.List<T>> buffer(long timespan, long timeshift, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
timeshift
argument, and on the
specified scheduler
. It emits each buffer after a fixed timespan, specified by the
timespan
argument. When the source Observable completes or encounters an error, the resulting
Observable emits the current buffer and propagates the notification from the source Observable.
Long.MAX_VALUE
upstream and does not obey downstream requests.Scheduler
this operator will usetimespan
- the period of time each buffer collects items before it is emittedtimeshift
- the period of time after which a new buffer will be createdunit
- the unit of time that applies to the timespan
and timeshift
argumentsscheduler
- the Scheduler
to use when determining the end and start of a bufferpublic final Observable<java.util.List<T>> buffer(long timespan, java.util.concurrent.TimeUnit unit)
timespan
argument. When the source Observable completes or encounters an error, the resulting
Observable emits the current buffer and propagates the notification from the source Observable.
Long.MAX_VALUE
upstream and does not obey downstream requests.buffer
operates by default on the computation
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 the timespan
argumentpublic final Observable<java.util.List<T>> buffer(long timespan, java.util.concurrent.TimeUnit unit, int count)
timespan
argument or a maximum size specified by the count
argument (whichever is reached
first). When the source Observable completes or encounters an error, the resulting Observable emits the
current buffer and propagates the notification from the source Observable.
Long.MAX_VALUE
upstream and does not obey downstream requests.buffer
operates by default on the computation
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 the timespan
argumentcount
- the maximum size of each buffer before it is emittedpublic final Observable<java.util.List<T>> buffer(long timespan, java.util.concurrent.TimeUnit unit, int count, Scheduler scheduler)
timespan
argument as measured on the specified scheduler
, or a maximum size specified by
the count
argument (whichever is reached first). When the source Observable completes or
encounters an error, the resulting Observable emits the current buffer and propagates the notification
from the source Observable.
Long.MAX_VALUE
upstream and does not obey downstream requests.Scheduler
this operator will usetimespan
- 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 the timespan
argumentcount
- the maximum size of each buffer before it is emittedscheduler
- the Scheduler
to use when determining the end and start of a bufferpublic final Observable<java.util.List<T>> buffer(long timespan, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
timespan
argument and on the specified scheduler
. When the source Observable completes or
encounters an error, the resulting Observable emits the current buffer and propagates the notification
from the source Observable.
Long.MAX_VALUE
upstream and does not obey downstream requests.Scheduler
this operator will usetimespan
- 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 the timespan
argumentscheduler
- the Scheduler
to use when determining the end and start of a bufferpublic final <TOpening,TClosing> Observable<java.util.List<T>> buffer(Observable<? extends TOpening> bufferOpenings, Func1<? super TOpening,? extends Observable<? extends TClosing>> bufferClosingSelector)
bufferOpenings
Observable emits an
item, and closes when the Observable returned from bufferClosingSelector
emits an item.
Long.MAX_VALUE
upstream and does not obey downstream requests.buffer
does not operate by default on a particular Scheduler
.TOpening
- the element type of the buffer-opening ObservableTClosing
- the element type of the individual buffer-closing ObservablesbufferOpenings
- the Observable that, when it emits an item, causes a new buffer to be createdbufferClosingSelector
- the Func1
that is used to produce an Observable for every buffer created. When this
Observable emits an item, the associated buffer is emitted.public final <B> Observable<java.util.List<T>> buffer(Observable<B> boundary)
Completion of either the source or the boundary Observable causes the returned Observable to emit the latest buffer and complete.
Observable
boundary
and buffers data. It requests Long.MAX_VALUE
upstream and does not obey
downstream requests.buffer
does not operate by default on a particular Scheduler
.B
- the boundary value type (ignored)boundary
- the boundary Observablebuffer(rx.Observable, int)
,
ReactiveX operators documentation: Bufferpublic final <B> Observable<java.util.List<T>> buffer(Observable<B> boundary, int initialCapacity)
Completion of either the source or the boundary Observable causes the returned Observable to emit the latest buffer and complete.
Observable
boundary
and buffers data. It requests Long.MAX_VALUE
upstream and does not obey
downstream requests.buffer
does not operate by default on a particular Scheduler
.B
- the boundary value type (ignored)boundary
- the boundary ObservableinitialCapacity
- the initial capacity of each buffer chunkbuffer(rx.Observable, int)
public final Observable<T> cache()
This is useful when you want an Observable to cache responses and you can't control the
subscribe/unsubscribe behavior of all the Subscriber
s.
The operator subscribes only when the first downstream subscriber subscribes and maintains
a single subscription towards this Observable. In contrast, the operator family of replay()
that return a ConnectableObservable
require an explicit call to ConnectableObservable.connect()
.
Note: You sacrifice the ability to unsubscribe from the origin when you use the cache
Observer so be careful not to use this Observer on Observables 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 via onTerminateDetach()
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 particular Scheduler
.@Deprecated public final Observable<T> cache(int initialCapacity)
cacheWithInitialCapacity(int)
instead.initialCapacity
- the capacity to start withcacheWithInitialCapacity(int)
public final Observable<T> cacheWithInitialCapacity(int initialCapacity)
This is useful when you want an Observable to cache responses and you can't control the
subscribe/unsubscribe behavior of all the Subscriber
s.
The operator subscribes only when the first downstream subscriber subscribes and maintains
a single subscription towards this Observable. In contrast, the operator family of replay()
that return a ConnectableObservable
require an explicit call to ConnectableObservable.connect()
.
Note: You sacrifice the ability to unsubscribe from the origin when you use the cache
Observer so be careful not to use this Observer on Observables 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 via onTerminateDetach()
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 particular Scheduler
.
Note: The capacity hint is not an upper bound on cache size. For that, consider
replay(int)
in combination with ConnectableObservable.autoConnect()
or similar.
initialCapacity
- hint for number of items to cache (for optimizing underlying data structure)public final <R> Observable<R> cast(java.lang.Class<R> klass)
Observable
's
backpressure behavior.cast
does not operate by default on a particular Scheduler
.R
- the output value type cast toklass
- the target class type that cast
will cast the items emitted by the source Observable
into before emitting them from the resulting Observablepublic final <R> Observable<R> collect(Func0<R> stateFactory, Action2<R,? super T> collector)
This is a simplified version of reduce
that does not need to return the state on each pass.
onNext
.collect
does not operate by default on a particular Scheduler
.R
- the accumulator and output typestateFactory
- the mutable data structure that will collect the itemscollector
- a function that accepts the state
and an emitted item, and modifies state
accordinglypublic final <R> Observable<R> concatMap(Func1<? super T,? extends Observable<? extends R>> func)
Observable
s are
expected to honor backpressure as well. If the source Observable
violates the rule, the operator will
signal a MissingBackpressureException
. If any of the inner Observable
s doesn't honor
backpressure, that may throw an IllegalStateException
when that
Observable
completes.concatMap
does not operate by default on a particular Scheduler
.R
- the type of the inner Observable sources and thus the output typefunc
- a function that, when applied to an item emitted by the source Observable, returns an
Observablepublic final <R> Observable<R> concatMapDelayError(Func1<? super T,? extends Observable<? extends R>> func)
Observable
s are
expected to honor backpressure as well. If the source Observable
violates the rule, the operator will
signal a MissingBackpressureException
. If any of the inner Observable
s doesn't honor
backpressure, that may throw an IllegalStateException
when that
Observable
completes.concatMapDelayError
does not operate by default on a particular Scheduler
.R
- the result value typefunc
- the function that maps the items of this Observable into the inner Observables.public final <R> Observable<R> concatMapIterable(Func1<? super T,? extends java.lang.Iterable<? extends R>> collectionSelector)
Observable
s is
expected to honor backpressure as well. If the source Observable
violates the rule, the operator will
signal a MissingBackpressureException
.concatMapIterable
does not operate by default on a particular Scheduler
.R
- the type of item emitted by the resulting ObservablecollectionSelector
- a function that returns an Iterable sequence of values for when given an item emitted by the
source ObservablecollectionSelector
public final Observable<T> concatWith(Observable<? extends T> t1)
other
Observable
s
are expected to honor backpressure as well. If any of then violates this rule, it may throw an
IllegalStateException
when the source Observable
completes.concat
does not operate by default on a particular Scheduler
.t1
- an Observable to be concatenated after the currentpublic final Observable<java.lang.Boolean> contains(java.lang.Object element)
Observable
in an
unbounded manner (i.e., without applying backpressure).contains
does not operate by default on a particular Scheduler
.element
- the item to search for in the emissions from the source Observabletrue
if the specified item is emitted by the source Observable,
or false
if the source Observable completes without emitting that itempublic final Observable<java.lang.Integer> count()
Observable
in an
unbounded manner (i.e., without applying backpressure).count
does not operate by default on a particular Scheduler
.countLong()
public final Observable<java.lang.Long> countLong()
Observable
in an
unbounded manner (i.e., without applying backpressure).countLong
does not operate by default on a particular Scheduler
.count()
public final <U> Observable<T> debounce(Func1<? super T,? extends Observable<U>> debounceSelector)
debounceSelector
to mark
boundaries.debounce
does not operate by default on a particular Scheduler
.U
- the debounce value type (ignored)debounceSelector
- function to retrieve a sequence that indicates the throttle duration for each itempublic final Observable<T> debounce(long timeout, java.util.concurrent.TimeUnit unit)
Note: If items keep being emitted by the source Observable faster than the timeout then no items will be emitted by the resulting Observable.
Information on debounce vs throttle:
debounce
operates by default on the computation
Scheduler
.timeout
- the time each item has to be "the most recent" of those emitted by the source Observable to
ensure that it's not droppedunit
- the TimeUnit
for the timeoutthrottleWithTimeout(long, TimeUnit)
public final Observable<T> debounce(long timeout, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
Note: If items keep being emitted by the source Observable faster than the timeout then no items will be emitted by the resulting Observable.
Information on debounce vs throttle:
Scheduler
this operator will usetimeout
- the time each item has to be "the most recent" of those emitted by the source Observable to
ensure that it's not droppedunit
- the unit of time for the specified timeoutscheduler
- the Scheduler
to use internally to manage the timers that handle the timeout for each
itemthrottleWithTimeout(long, TimeUnit, Scheduler)
public final Observable<T> defaultIfEmpty(T defaultValue)
Observable
is empty, this operator is guaranteed to honor backpressure from downstream.
If the source Observable
is non-empty, it is expected to honor backpressure as well; if the rule is violated,
a MissingBackpressureException
may get signalled somewhere downstream.
defaultIfEmpty
does not operate by default on a particular Scheduler
.defaultValue
- the item to emit if the source Observable emits no itemspublic final Observable<T> switchIfEmpty(Observable<? extends T> alternate)
Observable
is empty, the alternate Observable
is expected to honor backpressure.
If the source Observable
is non-empty, it is expected to honor backpressure as instead.
In either case, if violated, a MissingBackpressureException
may get
signalled somewhere downstream.
switchIfEmpty
does not operate by default on a particular Scheduler
.alternate
- the alternate Observable to subscribe to if the source does not emit any itemsjava.lang.NullPointerException
- if alternate
is nullpublic final <U,V> Observable<T> delay(Func0<? extends Observable<U>> subscriptionDelay, Func1<? super T,? extends Observable<V>> itemDelay)
Note: the resulting Observable will immediately propagate any onError
notification
from the source Observable.
Observable
.
All of the other Observable
s supplied by the functions are consumed
in an unbounded manner (i.e., no backpressure applied to them).delay
does not operate by default on a particular Scheduler
.U
- the subscription delay value type (ignored)V
- the item delay value type (ignored)subscriptionDelay
- a function that returns an Observable that triggers the subscription to the source Observable
once it emits any itemitemDelay
- a function that returns an Observable for each item emitted by the source Observable, which is
then used to delay the emission of that item by the resulting Observable until the Observable
returned from itemDelay
emits an itempublic final <U> Observable<T> delay(Func1<? super T,? extends Observable<U>> itemDelay)
Note: the resulting Observable will immediately propagate any onError
notification
from the source Observable.
Observable
.
All of the other Observable
s supplied by the function are consumed
in an unbounded manner (i.e., no backpressure applied to them).delay
does not operate by default on a particular Scheduler
.U
- the item delay value type (ignored)itemDelay
- a function that returns an Observable for each item emitted by the source Observable, which is
then used to delay the emission of that item by the resulting Observable until the Observable
returned from itemDelay
emits an itempublic final Observable<T> delay(long delay, java.util.concurrent.TimeUnit unit)
Observable
.delay
operates by default on the computation
Scheduler
.delay
- the delay to shift the source byunit
- the TimeUnit
in which period
is definedpublic final Observable<T> delay(long delay, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
Observable
.Scheduler
this operator will usedelay
- the delay to shift the source byunit
- the time unit of delay
scheduler
- the Scheduler
to use for delayingpublic final Observable<T> delaySubscription(long delay, java.util.concurrent.TimeUnit unit)
Observable
.delay
operates by default on the computation
Scheduler
.delay
- the time to delay the subscriptionunit
- the time unit of delay
public final Observable<T> delaySubscription(long delay, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
Observable
.Scheduler
this operator will usedelay
- the time to delay the subscriptionunit
- the time unit of delay
scheduler
- the Scheduler on which the waiting and subscription will happenpublic final <U> Observable<T> delaySubscription(Func0<? extends Observable<U>> subscriptionDelay)
Observable
.
The other Observable
s supplied by the function is consumed in an unbounded manner
(i.e., no backpressure applied to it).Scheduler
.U
- the element type of the delaying ObservablesubscriptionDelay
- a function that returns an Observable that triggers the subscription to the source Observable
once it emits any itemsubscriptionDelay
emits an itempublic final <U> Observable<T> delaySubscription(Observable<U> other)
Scheduler
.U
- the value type of the other Observable, irrelevantother
- the other Observable that should trigger the subscription
to this Observable.public final <T2> Observable<T2> dematerialize()
materialize
by transforming the
Notification
objects emitted by the source Observable into the items or notifications they
represent.
Observable
's
backpressure behavior.dematerialize
does not operate by default on a particular Scheduler
.T2
- the output value typeNotification
objects
emitted by the source ObservableOnErrorNotImplementedException
- if the source Observable is not of type Observable<Notification<T>>
public final Observable<T> distinct()
Observable
's
backpressure behavior.distinct
does not operate by default on a particular Scheduler
.public final <U> Observable<T> distinct(Func1<? super T,? extends U> keySelector)
Observable
's
backpressure behavior.distinct
does not operate by default on a particular Scheduler
.U
- 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 notpublic final Observable<T> distinctUntilChanged()
Observable
's
backpressure behavior.distinctUntilChanged
does not operate by default on a particular Scheduler
.public final <U> Observable<T> distinctUntilChanged(Func1<? super T,? extends U> keySelector)
Observable
's
backpressure behavior.distinctUntilChanged
does not operate by default on a particular Scheduler
.U
- 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 notpublic final Observable<T> distinctUntilChanged(Func2<? super T,? super T,java.lang.Boolean> comparator)
Observable
's
backpressure behavior.distinctUntilChanged
does not operate by default on a particular Scheduler
.comparator
- 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.public final Observable<T> doOnCompleted(Action0 onCompleted)
onCompleted
.
Observable
's
backpressure behavior.doOnCompleted
does not operate by default on a particular Scheduler
.onCompleted
- the action to invoke when the source Observable calls onCompleted
public final Observable<T> doOnEach(Action1<Notification<? super T>> onNotification)
Observable
's
backpressure behavior.doOnEach
does not operate by default on a particular Scheduler
.onNotification
- the action to invoke for each item emitted by the source Observablepublic final Observable<T> doOnEach(Observer<? super T> observer)
In case the onError
of the supplied observer throws, the downstream will receive a composite
exception containing the original exception and the exception thrown by onError
. If either the
onNext
or the onCompleted
method of the supplied observer throws, the downstream will be
terminated and will receive this thrown exception.
Observable
's
backpressure behavior.doOnEach
does not operate by default on a particular Scheduler
.observer
- the observer to be notified about onNext, onError and onCompleted events on its
respective methods before the actual downstream Subscriber gets notified.public final Observable<T> doOnError(Action1<? super java.lang.Throwable> onError)
onError
.
In case the onError
action throws, the downstream will receive a composite exception containing
the original exception and the exception thrown by onError
.
Observable
's
backpressure behavior.doOnError
does not operate by default on a particular Scheduler
.onError
- the action to invoke if the source Observable calls onError
public final Observable<T> doOnNext(Action1<? super T> onNext)
onNext
.
Observable
's
backpressure behavior.doOnNext
does not operate by default on a particular Scheduler
.onNext
- the action to invoke when the source Observable calls onNext
public final Observable<T> doOnRequest(Action1<? super java.lang.Long> onRequest)
Observable
so that it invokes the given action when it receives a
request for more items.
Note: This operator is for tracing the internal behavior of back-pressure request patterns and generally intended for debugging use.
Observable
's
backpressure behavior.doOnRequest
does not operate by default on a particular Scheduler
.onRequest
- the action that gets called when an observer requests items from this
Observable
Observable
modified so as to call this Action when appropriatepublic final Observable<T> doOnSubscribe(Action0 subscribe)
Observable
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
source Observable
is reference counted, in which case the source Observable
will invoke
the given action for the first subscription.
Observable
's
backpressure behavior.doOnSubscribe
does not operate by default on a particular Scheduler
.subscribe
- the action that gets called when an observer subscribes to the source Observable
Observable
modified so as to call this Action when appropriatepublic final Observable<T> doOnTerminate(Action0 onTerminate)
onCompleted
or
onError
.
This differs from finallyDo
in that this happens before the onCompleted
or
onError
notification.
Observable
's
backpressure behavior.doOnTerminate
does not operate by default on a particular Scheduler
.onTerminate
- the action to invoke when the source Observable calls onCompleted
or onError
finallyDo(Action0)
public final Observable<T> doOnUnsubscribe(Action0 unsubscribe)
Action0
if the downstream unsubscribes the sequence.
The action is shared between subscriptions and thus may be called concurrently from multiple threads; the action must be thread safe.
If the action throws a runtime exception, that exception is rethrown by the unsubscribe()
call,
sometimes as a CompositeException
if there were multiple exceptions along the way.
Note that terminal events trigger the action unless the Observable
is subscribed to via unsafeSubscribe()
.
doOnUnsubscribe
does not interact with backpressure requests or value delivery; backpressure
behavior is preserved between its upstream and its downstream.doOnUnsubscribe
does not operate by default on a particular Scheduler
.unsubscribe
- the action that gets called when the source Observable
is unsubscribedObservable
modified so as to call this Action when appropriatepublic static <T> Observable<T> concatEager(Observable<? extends T> o1, Observable<? extends T> o2)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source Observables. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typeo1
- the first sourceo2
- the second sourcepublic static <T> Observable<T> concatEager(Observable<? extends T> o1, Observable<? extends T> o2, Observable<? extends T> o3)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source Observables. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typeo1
- the first sourceo2
- the second sourceo3
- the third sourcepublic static <T> Observable<T> concatEager(Observable<? extends T> o1, Observable<? extends T> o2, Observable<? extends T> o3, Observable<? extends T> o4)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source Observables. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typeo1
- the first sourceo2
- the second sourceo3
- the third sourceo4
- the fourth sourcepublic static <T> Observable<T> concatEager(Observable<? extends T> o1, Observable<? extends T> o2, Observable<? extends T> o3, Observable<? extends T> o4, Observable<? extends T> o5)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source Observables. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typeo1
- the first sourceo2
- the second sourceo3
- the third sourceo4
- the fourth sourceo5
- the fifth sourcepublic static <T> Observable<T> concatEager(Observable<? extends T> o1, Observable<? extends T> o2, Observable<? extends T> o3, Observable<? extends T> o4, Observable<? extends T> o5, Observable<? extends T> o6)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source Observables. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typeo1
- the first sourceo2
- the second sourceo3
- the third sourceo4
- the fourth sourceo5
- the fifth sourceo6
- the sixth sourcepublic static <T> Observable<T> concatEager(Observable<? extends T> o1, Observable<? extends T> o2, Observable<? extends T> o3, Observable<? extends T> o4, Observable<? extends T> o5, Observable<? extends T> o6, Observable<? extends T> o7)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source Observables. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typeo1
- the first sourceo2
- the second sourceo3
- the third sourceo4
- the fourth sourceo5
- the fifth sourceo6
- the sixth sourceo7
- the seventh sourcepublic static <T> Observable<T> concatEager(Observable<? extends T> o1, Observable<? extends T> o2, Observable<? extends T> o3, Observable<? extends T> o4, Observable<? extends T> o5, Observable<? extends T> o6, Observable<? extends T> o7, Observable<? extends T> o8)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source Observables. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typeo1
- the first sourceo2
- the second sourceo3
- the third sourceo4
- the fourth sourceo5
- the fifth sourceo6
- the sixth sourceo7
- the seventh sourceo8
- the eighth sourcepublic static <T> Observable<T> concatEager(Observable<? extends T> o1, Observable<? extends T> o2, Observable<? extends T> o3, Observable<? extends T> o4, Observable<? extends T> o5, Observable<? extends T> o6, Observable<? extends T> o7, Observable<? extends T> o8, Observable<? extends T> o9)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source Observables. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typeo1
- the first sourceo2
- the second sourceo3
- the third sourceo4
- the fourth sourceo5
- the fifth sourceo6
- the sixth sourceo7
- the seventh sourceo8
- the eighth sourceo9
- the ninth sourcepublic static <T> Observable<T> concatEager(java.lang.Iterable<? extends Observable<? extends T>> sources)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source Observables. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typesources
- a sequence of Observables that need to be eagerly concatenatedpublic static <T> Observable<T> concatEager(java.lang.Iterable<? extends Observable<? extends T>> sources, int capacityHint)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source Observables. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typesources
- a sequence of Observables that need to be eagerly concatenatedcapacityHint
- hints about the number of expected source sequence valuespublic static <T> Observable<T> concatEager(Observable<? extends Observable<? extends T>> sources)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source Observables as they are observed. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typesources
- a sequence of Observables that need to be eagerly concatenatedpublic static <T> Observable<T> concatEager(Observable<? extends Observable<? extends T>> sources, int capacityHint)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source Observables as they are observed. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Scheduler
.T
- the value typesources
- a sequence of Observables that need to be eagerly concatenatedcapacityHint
- hints about the number of expected source sequence valuespublic final <R> Observable<R> concatMapEager(Func1<? super T,? extends Observable<? extends R>> mapper)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source Observables. The operator buffers the values emitted by these Observables 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 Observables that will be
eagerly concatenatedpublic final <R> Observable<R> concatMapEager(Func1<? super T,? extends Observable<? extends R>> mapper, int capacityHint)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source Observables. The operator buffers the values emitted by these Observables 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 Observables that will be
eagerly concatenatedcapacityHint
- hints about the number of expected source sequence valuespublic final <R> Observable<R> concatMapEager(Func1<? super T,? extends Observable<? extends R>> mapper, int capacityHint, int maxConcurrent)
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source Observables. The operator buffers the values emitted by these Observables 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 Observables that will be
eagerly concatenatedcapacityHint
- hints about the number of expected source sequence valuesmaxConcurrent
- the maximum number of concurrent subscribed observablespublic final Observable<T> elementAt(int index)
Observable
in an unbounded manner
(i.e., no backpressure applied to it).elementAt
does not operate by default on a particular Scheduler
.index
- the zero-based index of the item to retrievejava.lang.IndexOutOfBoundsException
- if index
is greater than or equal to the number of items emitted by the source
Observable, or
if index
is less than 0public final Observable<T> elementAtOrDefault(int index, T defaultValue)
Observable
in an unbounded manner
(i.e., no backpressure applied to it).elementAtOrDefault
does not operate by default on a particular Scheduler
.index
- the zero-based index of the item to retrievedefaultValue
- the default itemjava.lang.IndexOutOfBoundsException
- if index
is less than 0public final Observable<java.lang.Boolean> exists(Func1<? super T,java.lang.Boolean> predicate)
true
if any item emitted by the source Observable satisfies a
specified condition, otherwise false
. Note: this always emits false
if the
source Observable is empty.
In Rx.Net this is the any
Observer but we renamed it in RxJava to better match Java naming
idioms.
Observable
in an unbounded manner
(i.e., no backpressure applied to it).exists
does not operate by default on a particular Scheduler
.predicate
- the condition to test items emitted by the source Observablepredicate
public final Observable<T> filter(Func1<? super T,java.lang.Boolean> predicate)
Observable
's backpressure
behavior.filter
does not operate by default on a particular Scheduler
.predicate
- a function that evaluates each item emitted by the source Observable, returning true
if it passes the filtertrue
@Deprecated public final Observable<T> finallyDo(Action0 action)
doAfterTerminate(Action0)
instead.Action0
to be called when this Observable invokes either
onCompleted
or onError
.
Observable
's backpressure
behavior.finallyDo
does not operate by default on a particular Scheduler
.action
- an Action0
to be invoked when the source Observable finishesAction0
doOnTerminate(Action0)
public final Observable<T> doAfterTerminate(Action0 action)
Action0
to be called when this Observable invokes either
onCompleted
or onError
.
Observable
's backpressure
behavior.doAfterTerminate
does not operate by default on a particular Scheduler
.action
- an Action0
to be invoked when the source Observable finishesAction0
doOnTerminate(Action0)
public final Observable<T> first()
NoSuchElementException
if the source Observable is empty.
Observable
in an
unbounded manner (i.e., without applying backpressure).first
does not operate by default on a particular Scheduler
.NoSuchElementException
if the source Observable is emptypublic final Observable<T> first(Func1<? super T,java.lang.Boolean> predicate)
NoSuchElementException
if no such items are emitted.
Observable
in an
unbounded manner (i.e., without applying backpressure).first
does not operate by default on a particular Scheduler
.predicate
- the condition that an item emitted by the source Observable has to satisfypredicate
, or raises an NoSuchElementException
if no such items are emittedpublic final Observable<T> firstOrDefault(T defaultValue)
Observable
in an
unbounded manner (i.e., without applying backpressure).firstOrDefault
does not operate by default on a particular Scheduler
.defaultValue
- the default item to emit if the source Observable doesn't emit anythingpublic final Observable<T> firstOrDefault(T defaultValue, Func1<? super T,java.lang.Boolean> predicate)
Observable
in an
unbounded manner (i.e., without applying backpressure).firstOrDefault
does not operate by default on a particular Scheduler
.predicate
- the condition any item emitted by the source Observable has to satisfydefaultValue
- the default item to emit if the source Observable doesn't emit anything that satisfies the
predicate
predicate
, or a default item if the source Observable emits no such itemspublic final <R> Observable<R> flatMap(Func1<? super T,? extends Observable<? extends R>> func)
Observable
is consumed
in unbounded mode (i.e., no backpressure is applied to it). The inner Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.flatMap
does not operate by default on a particular Scheduler
.R
- the value type of the inner Observables and the output typefunc
- a function that, when applied to an item emitted by the source Observable, returns an
Observablepublic final <R> Observable<R> flatMap(Func1<? super T,? extends Observable<? extends R>> func, int maxConcurrent)
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.flatMap
does not operate by default on a particular Scheduler
.R
- the value type of the inner Observables and the output typefunc
- a function that, when applied to an item emitted by the source Observable, returns an
ObservablemaxConcurrent
- the maximum number of Observables that may be subscribed to concurrentlypublic final <R> Observable<R> flatMap(Func1<? super T,? extends Observable<? extends R>> onNext, Func1<? super java.lang.Throwable,? extends Observable<? extends R>> onError, Func0<? extends Observable<? extends R>> onCompleted)
Observable
is consumed
in unbounded mode (i.e., no backpressure is applied to it). The inner Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.flatMap
does not operate by default on a particular Scheduler
.R
- the result typeonNext
- a function that returns an Observable to merge for each item emitted by the source ObservableonError
- a function that returns an Observable to merge for an onError notification from the source
ObservableonCompleted
- a function that returns an Observable to merge for an onCompleted notification from the source
Observablepublic final <R> Observable<R> flatMap(Func1<? super T,? extends Observable<? extends R>> onNext, Func1<? super java.lang.Throwable,? extends Observable<? extends R>> onError, Func0<? extends Observable<? extends R>> onCompleted, int maxConcurrent)
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.flatMap
does not operate by default on a particular Scheduler
.R
- the result typeonNext
- a function that returns an Observable to merge for each item emitted by the source ObservableonError
- a function that returns an Observable to merge for an onError notification from the source
ObservableonCompleted
- a function that returns an Observable to merge for an onCompleted notification from the source
ObservablemaxConcurrent
- the maximum number of Observables that may be subscribed to concurrentlypublic final <U,R> Observable<R> flatMap(Func1<? super T,? extends Observable<? extends U>> collectionSelector, Func2<? super T,? super U,? extends R> resultSelector)
Observable
is consumed
in unbounded mode (i.e., no backpressure is applied to it). The inner Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.flatMap
does not operate by default on a particular Scheduler
.U
- the type of items emitted by the collection ObservableR
- the type of items emitted by the resulting ObservablecollectionSelector
- a function that returns an Observable for each item emitted by the source ObservableresultSelector
- a function that combines one item emitted by each of the source and collection Observables and
returns an item to be emitted by the resulting Observablepublic final <U,R> Observable<R> flatMap(Func1<? super T,? extends Observable<? extends U>> collectionSelector, Func2<? super T,? super U,? extends R> resultSelector, int maxConcurrent)
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.flatMap
does not operate by default on a particular Scheduler
.U
- the type of items emitted by the collection ObservableR
- the type of items emitted by the resulting ObservablecollectionSelector
- a function that returns an Observable for each item emitted by the source ObservableresultSelector
- a function that combines one item emitted by each of the source and collection Observables and
returns an item to be emitted by the resulting ObservablemaxConcurrent
- the maximum number of Observables that may be subscribed to concurrentlypublic final Observable<T> flatMapCompletable(Func1<? super T,? extends Completable> mapper)
flatMapCompletable
does not operate by default on a particular Scheduler
.History: 1.2.7 - experimental
mapper
- the function that receives an upstream value and turns it into a Completable
to be merged.flatMapCompletable(Func1, boolean, int)
public final Observable<T> flatMapCompletable(Func1<? super T,? extends Completable> mapper, boolean delayErrors)
flatMapCompletable
does not operate by default on a particular Scheduler
.History: 1.2.7 - experimental
mapper
- the function that receives an upstream value and turns it into a Completable
to be merged.delayErrors
- if true, errors from the upstream and from the inner Completables get delayed till
the all of them terminate.flatMapCompletable(Func1, boolean, int)
public final Observable<T> flatMapCompletable(Func1<? super T,? extends Completable> mapper, boolean delayErrors, int maxConcurrency)
flatMapCompletable
does not operate by default on a particular Scheduler
.History: 1.2.7 - experimental
mapper
- the function that receives an upstream value and turns it into a Completable
to be merged.delayErrors
- if true, errors from the upstream and from the inner Completables get delayed till
the all of them terminate.maxConcurrency
- the maximum number of inner Completables to run at a timepublic final <R> Observable<R> flatMapIterable(Func1<? super T,? extends java.lang.Iterable<? extends R>> collectionSelector)
Observable
s is
expected to honor backpressure as well. If the source Observable
violates the rule, the operator will
signal a MissingBackpressureException
.flatMapIterable
does not operate by default on a particular Scheduler
.R
- the type of item emitted by the resulting ObservablecollectionSelector
- a function that returns an Iterable sequence of values for when given an item emitted by the
source ObservablecollectionSelector
public final <R> Observable<R> flatMapIterable(Func1<? super T,? extends java.lang.Iterable<? extends R>> collectionSelector, int maxConcurrent)
Observable
s is
expected to honor backpressure as well. If the source Observable
violates the rule, the operator will
signal a MissingBackpressureException
.flatMapIterable
does not operate by default on a particular Scheduler
.R
- the type of item emitted by the resulting ObservablecollectionSelector
- a function that returns an Iterable sequence of values for when given an item emitted by the
source ObservablemaxConcurrent
- the maximum number of Observables that may be subscribed to concurrentlycollectionSelector
java.lang.IllegalArgumentException
- if maxConcurrent
is less than or equal to 0public final <U,R> Observable<R> flatMapIterable(Func1<? super T,? extends java.lang.Iterable<? extends U>> collectionSelector, Func2<? super T,? super U,? extends R> resultSelector)
Observable
s is
consumed in an unbounded manner (i.e., no backpressure is applied to it).flatMapIterable
does not operate by default on a particular Scheduler
.U
- the collection element typeR
- the type of item emitted by the resulting ObservablecollectionSelector
- a function that returns an Iterable sequence of values for each item emitted by the source
ObservableresultSelector
- a function that returns an item based on the item emitted by the source Observable and the
Iterable returned for that item by the collectionSelector
resultSelector
for each item in the source
Observablepublic final <U,R> Observable<R> flatMapIterable(Func1<? super T,? extends java.lang.Iterable<? extends U>> collectionSelector, Func2<? super T,? super U,? extends R> resultSelector, int maxConcurrent)
Observable
s is
expected to honor backpressure as well. If the source Observable
violates the rule, the operator will
signal a MissingBackpressureException
.flatMapIterable
does not operate by default on a particular Scheduler
.U
- the collection element typeR
- the type of item emitted by the resulting ObservablecollectionSelector
- a function that returns an Iterable sequence of values for each item emitted by the source
ObservableresultSelector
- a function that returns an item based on the item emitted by the source Observable and the
Iterable returned for that item by the collectionSelector
maxConcurrent
- the maximum number of Observables that may be subscribed to concurrentlyresultSelector
for each item in the source
Observablejava.lang.IllegalArgumentException
- if maxConcurrent
is less than or equal to 0public final <R> Observable<R> flatMapSingle(Func1<? super T,? extends Single<? extends R>> mapper)
flatMapSingle
does not operate by default on a particular Scheduler
.History: 1.2.7 - experimental
R
- the value type of the inner Singles and the resulting Observablemapper
- the function that receives an upstream value and turns it into a Single
to be merged.flatMapSingle(Func1, boolean, int)
public final <R> Observable<R> flatMapSingle(Func1<? super T,? extends Single<? extends R>> mapper, boolean delayErrors)
flatMapSingle
does not operate by default on a particular Scheduler
.History: 1.2.7 - experimental
R
- the value type of the inner Singles and the resulting Observablemapper
- the function that receives an upstream value and turns it into a Single
to be merged.delayErrors
- if true, errors from the upstream and from the inner Singles get delayed till
the all of them terminate.flatMapSingle(Func1, boolean, int)
public final <R> Observable<R> flatMapSingle(Func1<? super T,? extends Single<? extends R>> mapper, boolean delayErrors, int maxConcurrency)
flatMapSingle
does not operate by default on a particular Scheduler
.History: 1.2.7 - experimental
R
- the value type of the inner Singles and the resulting Observablemapper
- the function that receives an upstream value and turns it into a Single
to be merged.delayErrors
- if true, errors from the upstream and from the inner Singles get delayed till
the all of them terminate.maxConcurrency
- the maximum number of inner Singles to run at a timepublic final void forEach(Action1<? super T> onNext)
Observable
and receives notifications for each element.
Alias to subscribe(Action1)
Observable
in an unbounded manner (i.e., no
backpressure is applied to it).forEach
does not operate by default on a particular Scheduler
.onNext
- Action1
to execute for each item.java.lang.IllegalArgumentException
- if onNext
is nullOnErrorNotImplementedException
- if the Observable calls onError
public final void forEach(Action1<? super T> onNext, Action1<java.lang.Throwable> onError)
Observable
and receives notifications for each element and error events.
Alias to subscribe(Action1, Action1)
Observable
in an unbounded manner (i.e., no
backpressure is applied to it).forEach
does not operate by default on a particular Scheduler
.onNext
- Action1
to execute for each item.onError
- Action1
to execute when an error is emitted.java.lang.IllegalArgumentException
- if onNext
is null, or
if onError
is nullOnErrorNotImplementedException
- if the Observable calls onError
public final void forEach(Action1<? super T> onNext, Action1<java.lang.Throwable> onError, Action0 onComplete)
Observable
and receives notifications for each element and the terminal events.
Alias to subscribe(Action1, Action1, Action0)
Observable
in an unbounded manner (i.e., no
backpressure is applied to it).forEach
does not operate by default on a particular Scheduler
.onNext
- Action1
to execute for each item.onError
- Action1
to execute when an error is emitted.onComplete
- Action0
to execute when completion is signalled.java.lang.IllegalArgumentException
- if onNext
is null, or
if onError
is null, or
if onComplete
is nullOnErrorNotImplementedException
- if the Observable calls onError
public final <K,R> Observable<GroupedObservable<K,R>> groupBy(Func1<? super T,? extends K> keySelector, Func1<? super T,? extends R> elementSelector)
Observable
according to a specified criterion, and emits these
grouped items as GroupedObservable
s. The emitted GroupedObservable
allows only a single
Subscriber
during its lifetime and if this Subscriber
unsubscribes before the
source terminates, the next emission by the source having the same key will trigger a new
GroupedObservable
emission.
Note: A GroupedObservable
will cache the items it is to emit until such time as it
is subscribed to. For this reason, in order to avoid memory leaks, you should not simply ignore those
GroupedObservable
s that do not concern you. Instead, you can signal to them that they may
discard their buffers by applying an operator like ignoreElements()
to them.
Observable
s honor backpressure and the source Observable
is consumed in a bounded mode (i.e., requested a fixed amount upfront and replenished based on
downstream consumption). Note that both the returned and its inner Observable
s use
unbounded internal buffers and if the source Observable
doesn't honor backpressure, that may
lead to OutOfMemoryError
.groupBy
does not operate by default on a particular Scheduler
.K
- the key typeR
- the element typekeySelector
- a function that extracts the key for each itemelementSelector
- a function that extracts the return element for each itemObservable
that emits GroupedObservable
s, each of which corresponds to a
unique key value and each of which emits those items from the source Observable that share that
key value@Deprecated public final <K,R> Observable<GroupedObservable<K,R>> groupBy(Func1<? super T,? extends K> keySelector, Func1<? super T,? extends R> elementSelector, Func1<Action1<K>,java.util.Map<K,java.lang.Object>> evictingMapFactory)
groupBy(Func1, Func1, int, boolean, Func1)
instead which uses much less memory. Please take note of the
usage difference involving the evicting action which now expects
the value from the map instead of the key.Observable
according to a specified criterion, and emits these
grouped items as GroupedObservable
s. The emitted GroupedObservable
allows only a single
Subscriber
during its lifetime and if this Subscriber
unsubscribes before the
source terminates, the next emission by the source having the same key will trigger a new
GroupedObservable
emission.
Note: A GroupedObservable
will cache the items it is to emit until such time as it
is subscribed to. For this reason, in order to avoid memory leaks, you should not simply ignore those
GroupedObservable
s that do not concern you. Instead, you can signal to them that they may
discard their buffers by applying an operator like ignoreElements()
to them.
Observable
s honor backpressure and the source Observable
is consumed in a bounded mode (i.e., requested a fixed amount upfront and replenished based on
downstream consumption). Note that both the returned and its inner Observable
s use
unbounded internal buffers and if the source Observable
doesn't honor backpressure, that may
lead to OutOfMemoryError
.groupBy
does not operate by default on a particular Scheduler
.K
- the key typeR
- the element typekeySelector
- a function that extracts the key for each itemelementSelector
- a function that extracts the return element for each itemevictingMapFactory
- a function that given an eviction action returns a Map
instance that will be used to assign
items to the appropriate GroupedObservable
s. The Map
instance must be thread-safe
and any eviction must trigger a call to the supplied action (synchronously or asynchronously).
This can be used to limit the size of the map by evicting keys by maximum size or access time for
instance. Here's an example using Guava's CacheBuilder
from v19.0:
Func1<Action1<K>, Map<K, Object>> mapFactory
= action -> CacheBuilder.newBuilder()
.maximumSize(1000)
.expireAfterAccess(12, TimeUnit.HOURS)
.removalListener(notification -> action.call(notification.getKey()))
.<K, Object> build().asMap();
Observable
that emits GroupedObservable
s, each of which corresponds to a
unique key value and each of which emits those items from the source Observable that share that
key valuejava.lang.NullPointerException
- if evictingMapFactory
is null@Experimental public final <K,R> Observable<GroupedObservable<K,R>> groupBy(Func1<? super T,? extends K> keySelector, Func1<? super T,? extends R> elementSelector, int bufferSize, boolean delayError, Func1<Action1<java.lang.Object>,java.util.Map<K,java.lang.Object>> evictingMapFactory)
Observable
according to a specified criterion, and emits these
grouped items as GroupedObservable
s. The emitted GroupedObservable
allows only a single
Subscriber
during its lifetime and if this Subscriber
unsubscribes before the
source terminates, the next emission by the source having the same key will trigger a new
GroupedObservable
emission.
Note: A GroupedObservable
will cache the items it is to emit until such time as it
is subscribed to. For this reason, in order to avoid memory leaks, you should not simply ignore those
GroupedObservable
s that do not concern you. Instead, you can signal to them that they may
discard their buffers by applying an operator like ignoreElements()
to them.
Observable
s honor backpressure and the source Observable
is consumed in a bounded mode (i.e., requested a fixed amount upfront and replenished based on
downstream consumption). Note that both the returned and its inner Observable
s use
unbounded internal buffers and if the source Observable
doesn't honor backpressure, that may
lead to OutOfMemoryError
.groupBy
does not operate by default on a particular Scheduler
.K
- the key typeR
- the element typekeySelector
- a function that extracts the key for each itemelementSelector
- a function that extracts the return element for each itembufferSize
- the size of the buffer (RxRingBuffer.SIZE
may be suitable).delayError
- if and only if false then onError emissions can shortcut onNext emissions (emissions may be buffered)evictingMapFactory
- a function that given an eviction action returns a Map
instance that will be used to assign
items to the appropriate GroupedObservable
s. The Map
instance must be thread-safe
and any eviction must trigger a call to the supplied action (synchronously or asynchronously).
This can be used to limit the size of the map by evicting entries by map maximum size or access time for
instance. Here's an example using Guava's CacheBuilder
from v24.0:
Func1<Action1<Object>, Map<K, Object>> mapFactory
= action -> CacheBuilder.newBuilder()
.maximumSize(1000)
.expireAfterAccess(12, TimeUnit.HOURS)
.removalListener(entry -> action.call(entry.getValue()))
.<K, Object> build().asMap();
Observable
that emits GroupedObservable
s, each of which corresponds to a
unique key value and each of which emits those items from the source Observable that share that
key valuejava.lang.NullPointerException
- if evictingMapFactory
is nullpublic final <K> Observable<GroupedObservable<K,T>> groupBy(Func1<? super T,? extends K> keySelector)
Observable
according to a specified criterion, and emits these
grouped items as GroupedObservable
s. The emitted GroupedObservable
allows only a single
Subscriber
during its lifetime and if this Subscriber
unsubscribes before the
source terminates, the next emission by the source having the same key will trigger a new
GroupedObservable
emission.
Note: A GroupedObservable
will cache the items it is to emit until such time as it
is subscribed to. For this reason, in order to avoid memory leaks, you should not simply ignore those
GroupedObservable
s that do not concern you. Instead, you can signal to them that they may
discard their buffers by applying an operator like ignoreElements()
to them.
groupBy
does not operate by default on a particular Scheduler
.K
- the key typekeySelector
- a function that extracts the key for each itemObservable
that emits GroupedObservable
s, each of which corresponds to a
unique key value and each of which emits those items from the source Observable that share that
key valuepublic final <T2,D1,D2,R> Observable<R> groupJoin(Observable<T2> right, Func1<? super T,? extends Observable<D1>> leftDuration, Func1<? super T2,? extends Observable<D2>> rightDuration, Func2<? super T,? super Observable<T2>,? extends R> resultSelector)
There are no guarantees in what order the items get combined when multiple items from one or both source Observables overlap.
Observable
s in
an unbounded mode (i.e., not applying any backpressure to them).groupJoin
does not operate by default on a particular Scheduler
.T2
- the value type of the right Observable sourceD1
- the element type of the left duration ObservablesD2
- the element type of the right duration ObservablesR
- the result typeright
- the other Observable to correlate items from the source Observable withleftDuration
- a function that returns an Observable whose emissions indicate the duration of the values of
the source ObservablerightDuration
- a function that returns an Observable whose emissions indicate the duration of the values of
the right
ObservableresultSelector
- a function that takes an item emitted by each Observable and returns the value to be emitted
by the resulting Observablepublic final Observable<T> ignoreElements()
onCompleted
or onError
.
Observable
in an unbounded manner (i.e., no backpressure is applied to it).ignoreElements
does not operate by default on a particular Scheduler
.onCompleted
or onError
, based on which one is
called by the source Observablepublic final Observable<java.lang.Boolean> isEmpty()
true
if the source Observable is empty, otherwise false
.
In Rx.Net this is negated as the any
Observer but we renamed this in RxJava to better match Java
naming idioms.
Observable
in an
unbounded manner (i.e., without applying backpressure).isEmpty
does not operate by default on a particular Scheduler
.public final <TRight,TLeftDuration,TRightDuration,R> Observable<R> join(Observable<TRight> right, Func1<T,Observable<TLeftDuration>> leftDurationSelector, Func1<TRight,Observable<TRightDuration>> rightDurationSelector, Func2<T,TRight,R> resultSelector)
There are no guarantees in what order the items get combined when multiple items from one or both source Observables overlap.
Observable
s in
an unbounded mode (i.e., not applying any backpressure to them).join
does not operate by default on a particular Scheduler
.TRight
- the value type of the right Observable sourceTLeftDuration
- the element type of the left duration ObservablesTRightDuration
- the element type of the right duration ObservablesR
- the result typeright
- the second Observable to join items fromleftDurationSelector
- a function to select a duration for each item emitted by the source Observable, used to
determine overlaprightDurationSelector
- a function to select a duration for each item emitted by the right
Observable, used to
determine overlapresultSelector
- a function that computes an item to be emitted by the resulting Observable for any two
overlapping items emitted by the two Observablespublic final Observable<T> last()
NoSuchElementException
if the source Observable is empty.
Observable
in an
unbounded manner (i.e., without applying backpressure).last
does not operate by default on a particular Scheduler
.public final Observable<T> last(Func1<? super T,java.lang.Boolean> predicate)
NoSuchElementException
if no such items are emitted.
Observable
in an
unbounded manner (i.e., without applying backpressure).last
does not operate by default on a particular Scheduler
.predicate
- the condition any source emitted item has to satisfyNoSuchElementException
if no such items are emittedjava.lang.IllegalArgumentException
- if no items that match the predicate are emitted by the source Observablepublic final Observable<T> lastOrDefault(T defaultValue)
Observable
in an
unbounded manner (i.e., without applying backpressure).lastOrDefault
does not operate by default on a particular Scheduler
.defaultValue
- the default item to emit if the source Observable is emptypublic final Observable<T> lastOrDefault(T defaultValue, Func1<? super T,java.lang.Boolean> predicate)
Observable
in an
unbounded manner (i.e., without applying backpressure to it).lastOrDefault
does not operate by default on a particular Scheduler
.defaultValue
- the default item to emit if the source Observable doesn't emit anything that satisfies the
specified predicate
predicate
- the condition any item emitted by the source Observable has to satisfypublic final Observable<T> limit(int count)
count
items emitted by the source Observable.
Alias of take(int)
to match Java 8 Stream API naming convention.
This method returns an Observable that will invoke a subscribing Observer
's
onNext
function a maximum of count
times before invoking
onCompleted
.
Observable
's backpressure
behavior in case the first request is smaller than the count
. Otherwise, the source Observable
is consumed in an unbounded manner (i.e., without applying backpressure to it).limit
does not operate by default on a particular Scheduler
.count
- the maximum number of items to emitcount
items emitted by the source Observable, or
all of the items from the source Observable if that Observable emits fewer than count
itemspublic final <R> Observable<R> map(Func1<? super T,? extends R> func)
Observable
's backpressure
behavior.map
does not operate by default on a particular Scheduler
.R
- the output typefunc
- a function to apply to each item emitted by the Observablepublic final Observable<Notification<T>> materialize()
Notification
objects.
Observable
.
If this expectation is violated, the operator may throw an IllegalStateException
.materialize
does not operate by default on a particular Scheduler
.public final Observable<T> mergeWith(Observable<? extends T> t1)
You can combine items emitted by multiple Observables so that they appear as a single Observable, by
using the mergeWith
method.
Observable
s are expected to honor
backpressure; if violated, the operator may signal MissingBackpressureException
.mergeWith
does not operate by default on a particular Scheduler
.t1
- an Observable to be mergedpublic final Observable<T> observeOn(Scheduler scheduler)
Scheduler
,
asynchronously with a bounded buffer of RxRingBuffer.SIZE
slots.
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 the observeOn(Scheduler, boolean)
overload.
Observable
. Violating this
expectation will lead to MissingBackpressureException
. This is the most common operator where the exception
pops up; look for sources up the chain that don't support backpressure,
such as interval
, timer
, {code PublishSubject} or BehaviorSubject
and apply any
of the onBackpressureXXX
operators before applying observeOn
itself.Scheduler
this operator will usescheduler
- the Scheduler
to notify Observer
s onObserver
s are notified on the specified
Scheduler
subscribeOn(rx.Scheduler)
,
observeOn(Scheduler, int)
,
observeOn(Scheduler, boolean)
,
observeOn(Scheduler, boolean, int)
public final Observable<T> observeOn(Scheduler scheduler, int bufferSize)
Scheduler
,
asynchronously with a bounded buffer of configurable 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 the observeOn(Scheduler, boolean)
overload.
Observable
. Violating this
expectation will lead to MissingBackpressureException
. This is the most common operator where the exception
pops up; look for sources up the chain that don't support backpressure,
such as interval
, timer
, {code PublishSubject} or BehaviorSubject
and apply any
of the onBackpressureXXX
operators before applying observeOn
itself.Scheduler
this operator will usescheduler
- the Scheduler
to notify Observer
s onbufferSize
- the size of the buffer.Observer
s are notified on the specified
Scheduler
subscribeOn(rx.Scheduler)
,
observeOn(Scheduler)
,
observeOn(Scheduler, boolean)
,
observeOn(Scheduler, boolean, int)
public final Observable<T> observeOn(Scheduler scheduler, boolean delayError)
Scheduler
,
asynchronously with a bounded buffer and optionally delays onError notifications.
Observable
. Violating this
expectation will lead to MissingBackpressureException
. This is the most common operator where the exception
pops up; look for sources up the chain that don't support backpressure,
such as interval
, timer
, {code PublishSubject} or BehaviorSubject
and apply any
of the onBackpressureXXX
operators before applying observeOn
itself.Scheduler
this operator will usescheduler
- the Scheduler
to notify Observer
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 specified
Scheduler
subscribeOn(rx.Scheduler)
,
observeOn(Scheduler)
,
observeOn(Scheduler, int)
,
observeOn(Scheduler, boolean, int)
public final Observable<T> observeOn(Scheduler scheduler, boolean delayError, int bufferSize)
Scheduler
,
asynchronously with a bounded buffer of configurable size and optionally delays onError notifications.
Observable
. Violating this
expectation will lead to MissingBackpressureException
. This is the most common operator where the exception
pops up; look for sources up the chain that don't support backpressure,
such as interval
, timer
, {code PublishSubject} or BehaviorSubject
and apply any
of the onBackpressureXXX
operators before applying observeOn
itself.Scheduler
this operator will usescheduler
- the Scheduler
to notify Observer
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 specified
Scheduler
subscribeOn(rx.Scheduler)
,
observeOn(Scheduler)
,
observeOn(Scheduler, int)
,
observeOn(Scheduler, boolean)
public final <R> Observable<R> ofType(java.lang.Class<R> klass)
Observable
's backpressure
behavior.ofType
does not operate by default on a particular Scheduler
.R
- the output typeklass
- the class type to filter the items emitted by the source Observableklass
public final Observable<T> onBackpressureBuffer()
Observable
in an unbounded
manner (i.e., not applying backpressure to it).onBackpressureBuffer
does not operate by default on a particular Scheduler
.public final Observable<T> onBackpressureBuffer(long capacity)
onError
emitting
a BufferOverflowException
as soon as the buffer's capacity is exceeded, dropping all undelivered
items, and unsubscribing from the source.
Observable
in an unbounded
manner (i.e., not applying backpressure to it).onBackpressureBuffer
does not operate by default on a particular Scheduler
.capacity
- number of slots available in the buffer.Observable
modified to buffer items up to the given capacity.public final Observable<T> onBackpressureBuffer(long capacity, Action0 onOverflow)
onError
emitting
a BufferOverflowException
as soon as the buffer's capacity is exceeded, dropping all undelivered
items, unsubscribing from the source, and notifying the producer with onOverflow
.
Observable
in an unbounded
manner (i.e., not applying backpressure to it).onBackpressureBuffer
does not operate by default on a particular Scheduler
.capacity
- number of slots available in the buffer.onOverflow
- action to execute if an item needs to be buffered, but there are no available slots. Null is allowed.Observable
modified to buffer items up to the given capacitypublic final Observable<T> onBackpressureBuffer(long capacity, Action0 onOverflow, BackpressureOverflow.Strategy overflowStrategy)
overflowStrategy
if the buffer capacity is exceeded.
BackpressureOverflow.Strategy.ON_OVERFLOW_ERROR
(default) will onError
dropping all undelivered items,
unsubscribing from the source, and notifying the producer with onOverflow
. BackpressureOverflow.Strategy.ON_OVERFLOW_DROP_LATEST
will drop any new items emitted by the producer while
the buffer is full, without generating any onError
. Each drop will however invoke onOverflow
to signal the overflow to the producer.BackpressureOverflow.Strategy.ON_OVERFLOW_DROP_OLDEST
will drop the oldest items in the buffer in order to make
room for newly emitted ones. Overflow will not generate anonError
, but each drop will invoke
onOverflow
to signal the overflow to the producer.
Observable
in an unbounded
manner (i.e., not applying backpressure to it).onBackpressureBuffer
does not operate by default on a particular Scheduler
.capacity
- number of slots available in the buffer.onOverflow
- action to execute if an item needs to be buffered, but there are no available slots. Null is allowed.overflowStrategy
- how should the Observable
react to buffer overflows. Null is not allowed.Observable
modified to buffer items up to the given capacitypublic final Observable<T> onBackpressureDrop(Action1<? super T> onDrop)
If the downstream request count hits 0 then the Observable will refrain from calling onNext
until
the observer invokes request(n)
again to increase the request count.
Observable
in an unbounded
manner (i.e., not applying backpressure to it).onBackpressureDrop
does not operate by default on a particular Scheduler
.onDrop
- the action to invoke for each item dropped. onDrop action should be fast and should never block.onNext
notifications on overflowpublic final Observable<T> onBackpressureDrop()
If the downstream request count hits 0 then the Observable will refrain from calling onNext
until
the observer invokes request(n)
again to increase the request count.
Observable
in an unbounded
manner (i.e., not applying backpressure to it).onBackpressureDrop
does not operate by default on a particular Scheduler
.onNext
notifications on overflowpublic final Observable<T> onBackpressureLatest()
Its behavior is logically equivalent to toBlocking().latest()
with the exception that
the downstream is not blocking while requesting more values.
Note that if the upstream Observable does support backpressure, this operator ignores that capability and doesn't propagate any backpressure requests from downstream.
Note that due to the nature of how backpressure requests are propagated through subscribeOn/observeOn, requesting more than 1 from downstream doesn't guarantee a continuous delivery of onNext events.
Observable
in an unbounded
manner (i.e., not applying backpressure to it).onBackpressureLatest
does not operate by default on a particular Scheduler
.public final Observable<T> onErrorResumeNext(Func1<? super java.lang.Throwable,? extends Observable<? extends T>> resumeFunction)
onError
if it encounters an error.
By default, when an Observable encounters an error that prevents it from emitting the expected item to
its Observer
, the Observable invokes its Observer's onError
method, and then quits
without invoking any more of its Observer's methods. The onErrorResumeNext
method changes this
behavior. If you pass a function that returns an Observable (resumeFunction
) to
onErrorResumeNext
, if the original Observable encounters an error, instead of invoking its
Observer's onError
method, it will instead relinquish control to the Observable returned from
resumeFunction
, which will invoke the Observer's onNext
method if it is
able to do so. In such a case, because no Observable necessarily invokes onError
, 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.
Observable
s
are expected to honor backpressure as well.
If any of them violate this expectation, the operator may throw an
IllegalStateException
when the source Observable
completes or
a MissingBackpressureException
is signalled somewhere downstream.onErrorResumeNext
does not operate by default on a particular Scheduler
.resumeFunction
- a function that returns an Observable that will take over if the source Observable encounters
an errorpublic final Observable<T> onErrorResumeNext(Observable<? extends T> resumeSequence)
onError
if it encounters an error.
By default, when an Observable encounters an error that prevents it from emitting the expected item to
its Observer
, the Observable invokes its Observer's onError
method, and then quits
without invoking any more of its Observer's methods. The onErrorResumeNext
method changes this
behavior. If you pass another Observable (resumeSequence
) to an Observable's
onErrorResumeNext
method, if the original Observable encounters an error, instead of invoking its
Observer's onError
method, it will instead relinquish control to resumeSequence
which
will invoke the Observer's onNext
method if it is able to do so. In such a case,
because no Observable necessarily invokes onError
, 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.
Observable
s
are expected to honor backpressure as well.
If any of them violate this expectation, the operator may throw an
IllegalStateException
when the source Observable
completes or
MissingBackpressureException
is signalled somewhere downstream.onErrorResumeNext
does not operate by default on a particular Scheduler
.resumeSequence
- a function that returns an Observable that will take over if the source Observable encounters
an errorpublic final Observable<T> onErrorReturn(Func1<? super java.lang.Throwable,? extends T> resumeFunction)
onError
if it encounters an error.
By default, when an Observable encounters an error that prevents it from emitting the expected item to
its Observer
, the Observable invokes its Observer's onError
method, and then quits
without invoking any more of its Observer's methods. The onErrorReturn
method changes this
behavior. If you pass a function (resumeFunction
) to an Observable's onErrorReturn
method, if the original Observable encounters an error, instead of invoking its Observer's
onError
method, it will instead emit the return value of resumeFunction
.
You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
Observable
s is expected to honor
backpressure as well. If it this expectation is violated, the operator may throw
IllegalStateException
when the source Observable
completes or
MissingBackpressureException
is signalled somewhere downstream.onErrorReturn
does not operate by default on a particular Scheduler
.resumeFunction
- a function that returns an item that the new Observable will emit if the source Observable
encounters an errorpublic final Observable<T> onExceptionResumeNext(Observable<? extends T> resumeSequence)
onError
if it encounters an Exception
.
This differs from onErrorResumeNext(rx.functions.Func1<? super java.lang.Throwable, ? extends rx.Observable<? extends T>>)
in that this one does not handle Throwable
or Error
but lets those continue through.
By default, when an Observable encounters an exception that prevents it from emitting the expected item
to its Observer
, the Observable invokes its Observer's onError
method, and then quits
without invoking any more of its Observer's methods. The onExceptionResumeNext
method changes
this behavior. If you pass another Observable (resumeSequence
) to an Observable's
onExceptionResumeNext
method, if the original Observable encounters an exception, instead of
invoking its Observer's onError
method, it will instead relinquish control to
resumeSequence
which will invoke the Observer's onNext
method if it is
able to do so. In such a case, because no Observable necessarily invokes onError
, 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.
Observable
s
are expected to honor backpressure as well.
If any of them violate this expectation, the operator may throw an
IllegalStateException
when the source Observable
completes or
MissingBackpressureException
is signalled somewhere downstream.onExceptionResumeNext
does not operate by default on a particular Scheduler
.resumeSequence
- a function that returns an Observable that will take over if the source Observable encounters
an exceptionpublic final Observable<T> onTerminateDetach()
Observable
's backpressure
behavior.onTerminateDetach
does not operate by default on a particular Scheduler
.public final ConnectableObservable<T> publish()
ConnectableObservable
, which is a variety of Observable that waits until its
connect
method is called before it begins emitting items to those
Observer
s that have subscribed to it.
ConnectableObservable
honors backpressure for each of its Subscriber
s
and expects the source Observable
to honor backpressure as well. If this expectation is violated,
the operator will signal a MissingBackpressureException
to its Subscriber
s and disconnect.publish
does not operate by default on a particular Scheduler
.ConnectableObservable
that upon connection causes the source Observable to emit items
to its Observer
spublic final <R> Observable<R> publish(Func1<? super Observable<T>,? extends Observable<R>> selector)
ConnectableObservable
that shares a single subscription to the underlying sequence.
Observable
to honor backpressure and if this expectation is
violated, the operator will signal a MissingBackpressureException
through the Observable
provided to the function. Since the Observable
returned by the selector
may be
independent from the provided Observable
to the function, the output's backpressure behavior
is determined by this returned Observable
.publish
does not operate by default on a particular Scheduler
.R
- the type of items emitted by the resulting Observableselector
- a function that can use the multicasted source sequence as many times as needed, without
causing multiple subscriptions to the source sequence. Subscribers 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 sequencepublic final Observable<T> rebatchRequests(int n)
n
initially from the upstream and then 75% of n
subsequently
after 75% of n
values have been emitted to the downstream.
This operator allows preventing the downstream to trigger unbounded mode via request(Long.MAX_VALUE)
or compensate for the per-item overhead of small and frequent requests.
rebatchRequests
does not operate by default on a particular Scheduler
.n
- the initial request amount, further request will happen after 75% of this valuepublic final Observable<T> reduce(Func2<T,T,T> accumulator)
This technique, which is called "reduce" here, is sometimes called "aggregate," "fold," "accumulate,"
"compress," or "inject" in other programming contexts. Groovy, for instance, has an inject
method
that does a similar operation on lists.
reduce
does not operate by default on a particular Scheduler
.accumulator
- an accumulator function to be invoked on each item emitted by the source Observable, whose
result will be used in the next accumulator calljava.lang.IllegalArgumentException
- if the source Observable emits no itemspublic final <R> Observable<R> reduce(R initialValue, Func2<R,? super T,R> accumulator)
This technique, which is called "reduce" here, is sometimes called "aggregate," "fold," "accumulate,"
"compress," or "inject" in other programming contexts. Groovy, for instance, has an inject
method
that does a similar operation on lists.
Note that the initialValue
is shared among all subscribers to the resulting Observable
and may cause problems if it is mutable. To make sure each subscriber gets its own value, defer
the application of this operator via defer(Func0)
:
Observable<T> source = ...
Observable.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)))
);
reduce
does not operate by default on a particular Scheduler
.R
- the accumulator and output value typeinitialValue
- the initial (seed) accumulator valueaccumulator
- an accumulator function to be invoked on each item emitted by the source Observable, the
result of which will be used in the next accumulator callpublic final Observable<T> repeat()
Observable
to honor backpressure as well.
If this expectation is violated, the operator may throw an IllegalStateException
.repeat
operates by default on the trampoline
Scheduler
.public final Observable<T> repeat(Scheduler scheduler)
Observable
to honor backpressure as well.
If this expectation is violated, the operator may throw an IllegalStateException
.Scheduler
this operator will usescheduler
- the Scheduler to emit the items onpublic final Observable<T> repeat(long count)
count
times.
Observable
to honor backpressure as well.
If this expectation is violated, the operator may throw an IllegalStateException
.repeat
operates by default on the trampoline
Scheduler
.count
- the number of times the source Observable items are repeated, a count of 0 will yield an empty
sequencecount
timesjava.lang.IllegalArgumentException
- if count
is less than zeropublic final Observable<T> repeat(long count, Scheduler scheduler)
count
times, on a particular Scheduler.
Observable
to honor backpressure as well.
If this expectation is violated, the operator may throw an IllegalStateException
.Scheduler
this operator will usecount
- the number of times the source Observable items are repeated, a count of 0 will yield an empty
sequencescheduler
- the Scheduler
to emit the items oncount
times on a particular Schedulerpublic final Observable<T> repeatWhen(Func1<? super Observable<? extends java.lang.Void>,? extends Observable<?>> notificationHandler, Scheduler scheduler)
onCompleted
. An onCompleted
notification from the source will result in the emission of
a void
item to the Observable provided as an argument to the notificationHandler
function. If that Observable calls onComplete
or onError
then repeatWhen
will
call onCompleted
or onError
on the child subscription. Otherwise, this Observable will
resubscribe to the source Observable, on a particular Scheduler.
Observable
to honor backpressure as well.
If this expectation is violated, the operator may throw an IllegalStateException
.Scheduler
this operator will usenotificationHandler
- receives an Observable of notifications with which a user can complete or error, aborting the repeat.scheduler
- the Scheduler
to emit the items onpublic final Observable<T> repeatWhen(Func1<? super Observable<? extends java.lang.Void>,? extends Observable<?>> notificationHandler)
onCompleted
. An onCompleted
notification from the source will result in the emission of
a void
item to the Observable provided as an argument to the notificationHandler
function. If that Observable calls onComplete
or onError
then repeatWhen
will
call onCompleted
or onError
on the child subscription. Otherwise, this Observable will
resubscribe to the source observable.
Observable
to honor backpressure as well.
If this expectation is violated, the operator may throw an IllegalStateException
.repeatWhen
operates by default on the trampoline
Scheduler
.notificationHandler
- receives an Observable of notifications with which a user can complete or error, aborting the repeat.public final ConnectableObservable<T> replay()
ConnectableObservable
that shares a single subscription to the underlying Observable
that will replay all of its items and notifications to any future Observer
. A Connectable
Observable resembles an ordinary Observable, except that it does not begin emitting items when it is
subscribed to, but only when its connect
method is called.
replay
does not operate by default on a particular Scheduler
.ConnectableObservable
that upon connection causes the source Observable to emit its
items to its Observer
spublic final <R> Observable<R> replay(Func1<? super Observable<T>,? extends Observable<R>> selector)
ConnectableObservable
that shares a single subscription to the source Observable.
replay
does not operate by default on a particular Scheduler
.R
- the type of items emitted by the resulting Observableselector
- the selector function, which can use the multicasted sequence as many times as needed, without
causing multiple subscriptions to the ObservableConnectableObservable
that shares a single subscription to the source Observablepublic final <R> Observable<R> replay(Func1<? super Observable<T>,? extends Observable<R>> selector, int bufferSize)
ConnectableObservable
that shares a single subscription to the source Observable,
replaying bufferSize
notifications.
replay
does not operate by default on a particular Scheduler
.R
- the type of items emitted by the resulting Observableselector
- the selector function, which can use the multicasted sequence as many times as needed, without
causing multiple subscriptions to the ObservablebufferSize
- the buffer size that limits the number of items the connectable observable can replayConnectableObservable
that shares a single subscription to the source Observable
replaying no more than bufferSize
itemspublic final <R> Observable<R> replay(Func1<? super Observable<T>,? extends Observable<R>> selector, int bufferSize, long time, java.util.concurrent.TimeUnit unit)
ConnectableObservable
that shares a single subscription to the source Observable,
replaying no more than bufferSize
items that were emitted within a specified time window.
replay
operates by default on the computation
Scheduler
.R
- the type of items emitted by the resulting Observableselector
- a selector function, which can use the multicasted sequence as many times as needed, without
causing multiple subscriptions to the ObservablebufferSize
- the buffer size that limits the number of items the connectable observable can replaytime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit of time
ConnectableObservable
that shares a single subscription to the source Observable, and
replays no more than bufferSize
items that were emitted within the window defined by
time
public final <R> Observable<R> replay(Func1<? super Observable<T>,? extends Observable<R>> selector, int bufferSize, long time, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
ConnectableObservable
that shares a single subscription to the source Observable,
replaying no more than bufferSize
items that were emitted within a specified time window.
Scheduler
this operator will useR
- the type of items emitted by the resulting Observableselector
- a selector function, which can use the multicasted sequence as many times as needed, without
causing multiple subscriptions to the ObservablebufferSize
- the buffer size that limits the number of items the connectable observable can replaytime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit of time
scheduler
- the Scheduler that is the time source for the windowConnectableObservable
that shares a single subscription to the source Observable, and
replays no more than bufferSize
items that were emitted within the window defined by
time
java.lang.IllegalArgumentException
- if bufferSize
is less than zeropublic final <R> Observable<R> replay(Func1<? super Observable<T>,? extends Observable<R>> selector, int bufferSize, Scheduler scheduler)
ConnectableObservable
that shares a single subscription to the source Observable,
replaying a maximum of bufferSize
items.
Scheduler
this operator will useR
- the type of items emitted by the resulting Observableselector
- a selector function, which can use the multicasted sequence as many times as needed, without
causing multiple subscriptions to the ObservablebufferSize
- the buffer size that limits the number of items the connectable observable can replayscheduler
- the Scheduler on which the replay is observedConnectableObservable
that shares a single subscription to the source Observable,
replaying no more than bufferSize
notificationspublic final <R> Observable<R> replay(Func1<? super Observable<T>,? extends Observable<R>> selector, long time, java.util.concurrent.TimeUnit unit)
ConnectableObservable
that shares a single subscription to the source Observable,
replaying all items that were emitted within a specified time window.
replay
operates by default on the computation
Scheduler
.R
- the type of items emitted by the resulting Observableselector
- a selector function, which can use the multicasted sequence as many times as needed, without
causing multiple subscriptions to the Observabletime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit of time
ConnectableObservable
that shares a single subscription to the source Observable,
replaying all items that were emitted within the window defined by time
public final <R> Observable<R> replay(Func1<? super Observable<T>,? extends Observable<R>> selector, long time, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
ConnectableObservable
that shares a single subscription to the source Observable,
replaying all items that were emitted within a specified time window.
Scheduler
this operator will useR
- the type of items emitted by the resulting Observableselector
- a selector function, which can use the multicasted sequence as many times as needed, without
causing multiple subscriptions to the Observabletime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit of time
scheduler
- the scheduler that is the time source for the windowConnectableObservable
that shares a single subscription to the source Observable,
replaying all items that were emitted within the window defined by time
public final <R> Observable<R> replay(Func1<? super Observable<T>,? extends Observable<R>> selector, Scheduler scheduler)
ConnectableObservable
that shares a single subscription to the source Observable.
Scheduler
this operator will useR
- the type of items emitted by the resulting Observableselector
- a selector function, which can use the multicasted sequence as many times as needed, without
causing multiple subscriptions to the Observablescheduler
- the Scheduler where the replay is observedConnectableObservable
that shares a single subscription to the source Observable,
replaying all itemspublic final ConnectableObservable<T> replay(int bufferSize)
ConnectableObservable
that shares a single subscription to the source Observable that
replays at most bufferSize
items emitted by that Observable. A Connectable Observable resembles
an ordinary Observable, except that it does not begin emitting items when it is subscribed to, but only
when its connect
method is called.
replay
does not operate by default on a particular Scheduler
.bufferSize
- the buffer size that limits the number of items that can be replayedConnectableObservable
that shares a single subscription to the source Observable and
replays at most bufferSize
items emitted by that Observablepublic final ConnectableObservable<T> replay(int bufferSize, long time, java.util.concurrent.TimeUnit unit)
ConnectableObservable
that shares a single subscription to the source Observable and
replays at most bufferSize
items that were emitted during a specified time window. A Connectable
Observable resembles an ordinary Observable, except that it does not begin emitting items when it is
subscribed to, but only when its connect
method is called.
replay
operates by default on the computation
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 of time
ConnectableObservable
that shares a single subscription to the source Observable and
replays at most bufferSize
items that were emitted during the window defined by
time
public final ConnectableObservable<T> replay(int bufferSize, long time, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
ConnectableObservable
that shares a single subscription to the source Observable and
that replays a maximum of bufferSize
items that are emitted within a specified time window. A
Connectable Observable resembles an ordinary Observable, except that it does not begin emitting items
when it is subscribed to, but only when its connect
method is called.
Scheduler
this operator will usebufferSize
- 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 of time
scheduler
- the scheduler that is used as a time source for the windowConnectableObservable
that shares a single subscription to the source Observable and
replays at most bufferSize
items that were emitted during the window defined by
time
java.lang.IllegalArgumentException
- if bufferSize
is less than zeropublic final ConnectableObservable<T> replay(int bufferSize, Scheduler scheduler)
ConnectableObservable
that shares a single subscription to the source Observable and
replays at most bufferSize
items emitted by that Observable. A Connectable Observable resembles
an ordinary Observable, except that it does not begin emitting items when it is subscribed to, but only
when its connect
method is called.
Scheduler
this operator will usebufferSize
- 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 Observable and
replays at most bufferSize
items that were emitted by the Observablepublic final ConnectableObservable<T> replay(long time, java.util.concurrent.TimeUnit unit)
ConnectableObservable
that shares a single subscription to the source Observable and
replays all items emitted by that Observable within a specified time window. A Connectable Observable
resembles an ordinary Observable, except that it does not begin emitting items when it is subscribed to,
but only when its connect
method is called.
replay
operates by default on the computation
Scheduler
.time
- the duration of the window in which the replayed items must have been emittedunit
- the time unit of time
ConnectableObservable
that shares a single subscription to the source Observable and
replays the items that were emitted during the window defined by time
public final ConnectableObservable<T> replay(long time, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
ConnectableObservable
that shares a single subscription to the source Observable and
replays all items emitted by that Observable within a specified time window. A Connectable Observable
resembles an ordinary Observable, except that it does not begin emitting items when it is subscribed to,
but only when its connect
method is called.
Scheduler
this operator will usetime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit of time
scheduler
- the Scheduler that is the time source for the windowConnectableObservable
that shares a single subscription to the source Observable and
replays the items that were emitted during the window defined by time
public final ConnectableObservable<T> replay(Scheduler scheduler)
ConnectableObservable
that shares a single subscription to the source Observable that
will replay all of its items and notifications to any future Observer
on the given
Scheduler
. A Connectable Observable resembles an ordinary Observable, except that it does not
begin emitting items when it is subscribed to, but only when its connect
method is called.
Scheduler
this operator will usescheduler
- the Scheduler on which the Observers will observe the emitted itemsConnectableObservable
that shares a single subscription to the source Observable that
will replay all of its items and notifications to any future Observer
on the given
Scheduler
public final Observable<T> retry()
onError
(infinite retry count).
If the source Observable calls Observer.onError(java.lang.Throwable)
, this method will resubscribe to the source
Observable rather than propagating the onError
call.
Any and all items emitted by the source Observable will be emitted by the resulting Observable, even
those emitted during failed subscriptions. For example, if an Observable 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, onCompleted]
.
Observable
to honor backpressure as well.
If this expectation is violated, the operator may throw an IllegalStateException
.retry
operates by default on the trampoline
Scheduler
.public final Observable<T> retry(long count)
onError
up to a specified number of retries.
If the source Observable calls Observer.onError(java.lang.Throwable)
, this method will resubscribe to the source
Observable for a maximum of count
resubscriptions rather than propagating the
onError
call.
Any and all items emitted by the source Observable will be emitted by the resulting Observable, even
those emitted during failed subscriptions. For example, if an Observable 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, onCompleted]
.
Observable
to honor backpressure as well.
If this expectation is violated, the operator may throw an IllegalStateException
.retry
operates by default on the trampoline
Scheduler
.count
- number of retry attempts before failingpublic final Observable<T> retry(Func2<java.lang.Integer,java.lang.Throwable,java.lang.Boolean> predicate)
onError
and the predicate returns true for that specific exception and retry count.
Observable
to honor backpressure as well.
If this expectation is violated, the operator may throw an IllegalStateException
.retry
operates by default on the trampoline
Scheduler
.predicate
- the predicate that determines if a resubscription may happen in case of a specific exception
and retry countretry()
,
ReactiveX operators documentation: Retrypublic final Observable<T> retryWhen(Func1<? super Observable<? extends java.lang.Throwable>,? extends Observable<?>> notificationHandler)
onError
. An onError
notification from the source will result in the emission of a
Throwable
item to the Observable provided as an argument to the notificationHandler
function. If that Observable calls onComplete
or onError
then retry
will call
onCompleted
or onError
on the child subscription. Otherwise, this Observable will
resubscribe to the source Observable.
Example: This retries 3 times, each time incrementing the number of seconds it waits.
Observable.create((Subscriber 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);
});
}).toBlocking().forEach(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
Observable
to honor backpressure as well.
If this expectation is violated, the operator may throw an IllegalStateException
.retryWhen
operates by default on the trampoline
Scheduler
.notificationHandler
- receives an Observable of notifications with which a user can complete or error, aborting the
retrypublic final Observable<T> retryWhen(Func1<? super Observable<? extends java.lang.Throwable>,? extends Observable<?>> notificationHandler, Scheduler scheduler)
onError
. An onError
will cause the emission of the Throwable
that cause the
error to the Observable returned from notificationHandler
. If that Observable calls
onComplete
or onError
then retry
will call onCompleted
or onError
on the child subscription. Otherwise, this Observable will resubscribe to the source observable, on a
particular Scheduler.
Observable
to honor backpressure as well.
If this expectation is violated, the operator may throw an IllegalStateException
.Scheduler
this operator will usenotificationHandler
- receives an Observable of notifications with which a user can complete or error, aborting the
retryscheduler
- the Scheduler
on which to subscribe to the source Observablepublic final Observable<T> sample(long period, java.util.concurrent.TimeUnit unit)
sample
operates by default on the computation
Scheduler
.period
- the sampling rateunit
- the TimeUnit
in which period
is definedthrottleLast(long, TimeUnit)
public final Observable<T> sample(long period, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
Scheduler
this operator will useperiod
- the sampling rateunit
- the TimeUnit
in which period
is definedscheduler
- the Scheduler
to use when samplingthrottleLast(long, TimeUnit, Scheduler)
public final <U> Observable<T> sample(Observable<U> sampler)
sampler
Observable emits an item or completes,
emits the most recently emitted item (if any) emitted by the source Observable since the previous
emission from the sampler
Observable.
sampler
Observable to control data flow.sample
does not operate by default on a particular Scheduler
.U
- the element type of the sampler Observablesampler
- the Observable to use for sampling the source Observablesampler
Observable emits an item or completespublic final Observable<T> scan(Func2<T,T,T> accumulator)
This sort of function is sometimes called an accumulator.
Observable
to honor backpressure as well.
Violating this expectation, a MissingBackpressureException
may get signalled somewhere downstream.scan
does not operate by default on a particular Scheduler
.accumulator
- an accumulator function to be invoked on each item emitted by the source Observable, whose
result will be emitted to Observer
s via onNext
and used in the
next accumulator callpublic final <R> Observable<R> scan(R initialValue, Func2<R,? super T,R> accumulator)
This sort of function is sometimes called an accumulator.
Note that the Observable that results from this method will emit initialValue
as its first
emitted item.
Note that the initialValue
is shared among all subscribers to the resulting Observable
and may cause problems if it is mutable. To make sure each subscriber gets its own value, defer
the application of this operator via defer(Func0)
:
Observable<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)))
);
Observable
to honor backpressure as well.
Violating this expectation, a MissingBackpressureException
may get signalled somewhere downstream.scan
does not operate by default on a particular Scheduler
.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 Observable, whose
result will be emitted to Observer
s via onNext
and used in the
next accumulator callinitialValue
followed by the results of each call to the
accumulator functionpublic final Observable<T> serialize()
It is possible for an Observable to invoke its Subscribers' methods asynchronously, perhaps from
different threads. This could make such an Observable poorly-behaved, in that it might try to invoke
onCompleted
or onError
before one of its onNext
invocations, or it might call
onNext
from two different threads concurrently. You can force such an Observable to be
well-behaved and sequential by applying the serialize
method to it.
Observable
's backpressure
behavior.serialize
does not operate by default on a particular Scheduler
.Observable
that is guaranteed to be well-behaved and to make only serialized calls to
its observerspublic final Observable<T> share()
Observable
that multicasts (shares) the original Observable
. As long as
there is at least one Subscriber
this Observable
will be subscribed and emitting data.
When all subscribers have unsubscribed it will unsubscribe from the source Observable
.
This is an alias for publish()
.ConnectableObservable.refCount()
.
Observable
to honor backpressure as well.
If this expectation is violated, the operator will signal a MissingBackpressureException
to
its Subscriber
s.share
does not operate by default on a particular Scheduler
.Observable
that upon connection causes the source Observable
to emit items
to its Observer
spublic final Observable<T> single()
IllegalArgumentException
or NoSuchElementException
respectively.
Observable
in an
unbounded manner (i.e., without applying backpressure).single
does not operate by default on a particular Scheduler
.java.lang.IllegalArgumentException
- if the source emits more than one itemjava.util.NoSuchElementException
- if the source emits no itemspublic final Observable<T> single(Func1<? super T,java.lang.Boolean> predicate)
IllegalArgumentException
or
NoSuchElementException
respectively.
Observable
in an
unbounded manner (i.e., without applying backpressure).single
does not operate by default on a particular Scheduler
.predicate
- a predicate function to evaluate items emitted by the source Observablejava.lang.IllegalArgumentException
- if the source Observable emits more than one item that matches the predicatejava.util.NoSuchElementException
- if the source Observable emits no item that matches the predicatepublic final Observable<T> singleOrDefault(T defaultValue)
IllegalArgumentException
.
Observable
in an
unbounded manner (i.e., without applying backpressure).singleOrDefault
does not operate by default on a particular Scheduler
.defaultValue
- a default value to emit if the source Observable emits no itemjava.lang.IllegalArgumentException
- if the source Observable emits more than one itempublic final Observable<T> singleOrDefault(T defaultValue, Func1<? super T,java.lang.Boolean> predicate)
IllegalArgumentException
.
Observable
in an
unbounded manner (i.e., without applying backpressure).singleOrDefault
does not operate by default on a particular Scheduler
.defaultValue
- a default item to emit if the source Observable emits no matching itemspredicate
- a predicate function to evaluate items emitted by the source Observablejava.lang.IllegalArgumentException
- if the source Observable emits more than one item that matches the predicatepublic final Observable<T> skip(int count)
count
items emitted by the source Observable and emits
the remainder.
Observable
's backpressure
behavior.skip
does not operate by default on a particular Scheduler
.count
- the number of items to skipcount
items that the source Observable emitspublic final Observable<T> skip(long time, java.util.concurrent.TimeUnit unit)
Observable
in an unbounded manner (i.e., no backpressure applied to it).skip
operates by default on the computation
Scheduler
.time
- the length of the time window to skipunit
- the time unit of time
time
elapses and the emits the remainderpublic final Observable<T> skip(long time, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
Scheduler
elapses.
Observable
in an unbounded manner (i.e., no backpressure applied to it).Scheduler
this operator will usetime
- the length of the time window to skipunit
- the time unit of time
scheduler
- the Scheduler
on which the timed wait happenstime
and scheduler
elapses, and then emits the remainderpublic final Observable<T> skipLast(int count)
This Observer accumulates a queue long enough to store the first count
items. As more items are
received, items are taken from the front of the queue and emitted by the returned Observable. This causes
such items to be delayed.
Observable
's backpressure
behavior.skipLast
does not operate by default on a particular Scheduler
.count
- number of items to drop from the end of the source sequencejava.lang.IndexOutOfBoundsException
- if count
is less than zeropublic final Observable<T> skipLast(long time, java.util.concurrent.TimeUnit unit)
Note: this action will cache the latest items arriving in the specified time window.
Observable
in an unbounded manner (i.e., no backpressure applied to it).skipLast
operates by default on the computation
Scheduler
.time
- the length of the time windowunit
- the time unit of time
time
public final Observable<T> skipLast(long time, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
Note: this action will cache the latest items arriving in the specified time window.
Observable
in an unbounded manner (i.e., no backpressure applied to it).Scheduler
this operator will usetime
- the length of the time windowunit
- the time unit of time
scheduler
- the scheduler used as the time sourcetime
and scheduler
public final <U> Observable<T> skipUntil(Observable<U> other)
Observable
's backpressure
behavior.skipUntil
does not operate by default on a particular Scheduler
.U
- the element type of the other Observableother
- the second Observable that has to emit an item before the source Observable's elements begin
to be mirrored by the resulting Observablepublic final Observable<T> skipWhile(Func1<? super T,java.lang.Boolean> predicate)
Observable
's backpressure
behavior.skipWhile
does not operate by default on a particular Scheduler
.predicate
- a function to test each item emitted from the source Observablepublic final Observable<T> startWith(Observable<T> values)
Observable
before it begins to emit
items emitted by the source Observable.
other
Observable
s
are expected to honor backpressure as well. If any of then violates this rule, it may throw an
IllegalStateException
when the source Observable
completes.startWith
does not operate by default on a particular Scheduler
.values
- an Observable that contains the items you want the modified Observable to emit firstObservable
and then emits the items
emitted by the source Observablepublic final Observable<T> startWith(java.lang.Iterable<T> values)
Iterable
before it begins to emit items
emitted by the source Observable.
Observable
is expected to honor backpressure as well. If it violates this rule, it may throw an
IllegalStateException
when the source Observable
completes.startWith
does not operate by default on a particular Scheduler
.values
- an Iterable that contains the items you want the modified Observable to emit firstIterable
and then emits the items
emitted by the source Observablepublic final Observable<T> startWith(T t1)
Observable
is expected to honor backpressure as well. If it violates this rule, it may throw an
IllegalStateException
when the source Observable
completes.startWith
does not operate by default on a particular Scheduler
.t1
- the item to emitpublic final Observable<T> startWith(T t1, T t2)
Observable
is expected to honor backpressure as well. If it violates this rule, it may throw an
IllegalStateException
when the source Observable
completes.startWith
does not operate by default on a particular Scheduler
.t1
- the first item to emitt2
- the second item to emitpublic final Observable<T> startWith(T t1, T t2, T t3)
Observable
is expected to honor backpressure as well. If it violates this rule, it may throw an
IllegalStateException
when the source Observable
completes.startWith
does not operate by default on a particular Scheduler
.t1
- the first item to emitt2
- the second item to emitt3
- the third item to emitpublic final Observable<T> startWith(T t1, T t2, T t3, T t4)
Observable
is expected to honor backpressure as well. If it violates this rule, it may throw an
IllegalStateException
when the source Observable
completes.startWith
does not operate by default on a particular Scheduler
.t1
- the first item to emitt2
- the second item to emitt3
- the third item to emitt4
- the fourth item to emitpublic final Observable<T> startWith(T t1, T t2, T t3, T t4, T t5)
Observable
is expected to honor backpressure as well. If it violates this rule, it may throw an
IllegalStateException
when the source Observable
completes.startWith
does not operate by default on a particular Scheduler
.t1
- the first item to emitt2
- the second item to emitt3
- the third item to emitt4
- the fourth item to emitt5
- the fifth item to emitpublic final Observable<T> startWith(T t1, T t2, T t3, T t4, T t5, T t6)
Observable
is expected to honor backpressure as well. If it violates this rule, it may throw an
IllegalStateException
when the source Observable
completes.startWith
does not operate by default on a particular Scheduler
.t1
- the first item to emitt2
- the second item to emitt3
- the third item to emitt4
- the fourth item to emitt5
- the fifth item to emitt6
- the sixth item to emitpublic final Observable<T> startWith(T t1, T t2, T t3, T t4, T t5, T t6, T t7)
Observable
is expected to honor backpressure as well. If it violates this rule, it may throw an
IllegalStateException
when the source Observable
completes.startWith
does not operate by default on a particular Scheduler
.t1
- the first item to emitt2
- the second item to emitt3
- the third item to emitt4
- the fourth item to emitt5
- the fifth item to emitt6
- the sixth item to emitt7
- the seventh item to emitpublic final Observable<T> startWith(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T t8)
Observable
is expected to honor backpressure as well. If it violates this rule, it may throw an
IllegalStateException
when the source Observable
completes.startWith
does not operate by default on a particular Scheduler
.t1
- the first item to emitt2
- the second item to emitt3
- the third item to emitt4
- the fourth item to emitt5
- the fifth item to emitt6
- the sixth item to emitt7
- the seventh item to emitt8
- the eighth item to emitpublic final Observable<T> startWith(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T t8, T t9)
Observable
is expected to honor backpressure as well. If it violates this rule, it may throw an
IllegalStateException
when the source Observable
completes.startWith
does not operate by default on a particular Scheduler
.t1
- the first item to emitt2
- the second item to emitt3
- the third item to emitt4
- the fourth item to emitt5
- the fifth item to emitt6
- the sixth item to emitt7
- the seventh item to emitt8
- the eighth item to emitt9
- the ninth item to emitpublic final Subscription subscribe()
onNext
and onCompleted
emissions. If an onError
emission arrives then
OnErrorNotImplementedException
is thrown.
Observable
in an unbounded manner (i.e., no
backpressure is applied to it).subscribe
does not operate by default on a particular Scheduler
.Subscription
reference with which the Observer
can stop receiving items before
the Observable has finished sending themOnErrorNotImplementedException
- if the Observable tries to call onError
public final Subscription subscribe(Action1<? super T> onNext)
Observable
in an unbounded manner (i.e., no
backpressure is applied to it).subscribe
does not operate by default on a particular Scheduler
.onNext
- the Action1<T>
you have designed to accept emissions from the ObservableSubscription
reference with which the Observer
can stop receiving items before
the Observable has finished sending themjava.lang.IllegalArgumentException
- if onNext
is nullOnErrorNotImplementedException
- if the Observable calls onError
public final Subscription subscribe(Action1<? super T> onNext, Action1<java.lang.Throwable> onError)
Observable
in an unbounded manner (i.e., no
backpressure is applied to it).subscribe
does not operate by default on a particular Scheduler
.onNext
- the Action1<T>
you have designed to accept emissions from the ObservableonError
- the Action1<Throwable>
you have designed to accept any error notification from the
ObservableSubscription
reference with which the Observer
can stop receiving items before
the Observable has finished sending themjava.lang.IllegalArgumentException
- if onNext
is null, or
if onError
is nullpublic final Subscription subscribe(Action1<? super T> onNext, Action1<java.lang.Throwable> onError, Action0 onCompleted)
Observable
in an unbounded manner (i.e., no
backpressure is applied to it).subscribe
does not operate by default on a particular Scheduler
.onNext
- the Action1<T>
you have designed to accept emissions from the ObservableonError
- the Action1<Throwable>
you have designed to accept any error notification from the
ObservableonCompleted
- the Action0
you have designed to accept a completion notification from the
ObservableSubscription
reference with which the Observer
can stop receiving items before
the Observable has finished sending themjava.lang.IllegalArgumentException
- if onNext
is null, or
if onError
is null, or
if onComplete
is nullpublic final Subscription subscribe(Observer<? super T> observer)
Observable
in an unbounded manner (i.e., no
backpressure is applied to it).subscribe
does not operate by default on a particular Scheduler
.observer
- the Observer that will handle emissions and notifications from the ObservableSubscription
reference with which the Observer
can stop receiving items before
the Observable has completedpublic final Subscription unsafeSubscribe(Subscriber<? super T> subscriber)
Observable.OnSubscribe
function without any contract protection,
error handling, unsubscribe, or execution hooks.
Use this only for implementing an Observable.Operator
that requires nested subscriptions. For other
purposes, use subscribe(Subscriber)
which ensures
the Observable contract and other
functionality.
Observable
's backpressure
behavior.unsafeSubscribe
does not operate by default on a particular Scheduler
.subscriber
- the Subscriber that will handle emissions and notifications from the ObservableSubscription
reference with which the Subscriber
can stop receiving items
before the Observable has completedpublic final Subscription subscribe(Subscriber<? super T> subscriber)
A typical implementation of subscribe
does the following:
List<T>
object.Subscription
interface. This enables Subscribers to
unsubscribe, that is, to stop receiving items and notifications before the Observable completes, which
also invokes the Subscriber's onCompleted
method.
An Observable<T>
instance is responsible for accepting all subscriptions and notifying all
Subscribers. Unless the documentation for a particular Observable<T>
implementation indicates
otherwise, Subscriber should make no assumptions about the order in which multiple Subscribers will
receive their notifications.
For more information see the ReactiveX documentation.
Observable
's backpressure
behavior.subscribe
does not operate by default on a particular Scheduler
.subscriber
- the Subscriber
that will handle emissions and notifications from the ObservableSubscription
reference with which Subscribers that are Observer
s can
unsubscribe from the Observablejava.lang.IllegalStateException
- if subscribe
is unable to obtain an OnSubscribe<>
functionjava.lang.IllegalArgumentException
- if the Subscriber
provided as the argument to subscribe
is null
OnErrorNotImplementedException
- if the Subscriber
's onError
method is nulljava.lang.RuntimeException
- if the Subscriber
's onError
method itself threw a Throwable
public final Observable<T> subscribeOn(Scheduler scheduler)
Scheduler
.
If there is a create(Action1, rx.Emitter.BackpressureMode)
type source up in the
chain, it is recommended to use subscribeOn(scheduler, false)
instead
to avoid same-pool deadlock because requests pile up behind a eager/blocking emitter.
Observable
's backpressure
behavior. However, the upstream is requested from the given scheduler thread.Scheduler
this operator will usescheduler
- the Scheduler
to perform subscription actions onScheduler
observeOn(rx.Scheduler)
,
subscribeOn(Scheduler, boolean)
public final Observable<T> subscribeOn(Scheduler scheduler, boolean requestOn)
Scheduler
and
optionally reroutes requests from other threads to the same Scheduler
thread.
If there is a create(Action1, rx.Emitter.BackpressureMode)
type source up in the
chain, it is recommended to have requestOn
false to avoid same-pool deadlock
because requests pile up behind a eager/blocking emitter.
Observable
's backpressure
behavior. However, the upstream is requested from the given scheduler if requestOn is true.Scheduler
this operator will useHistory: 1.2.7 - experimental
scheduler
- the Scheduler
to perform subscription actions onrequestOn
- if true, requests are rerouted to the given Scheduler as well (strong pipelining)
if false, requests coming from any thread are simply forwarded to
the upstream on the same thread (weak pipelining)Scheduler
observeOn(rx.Scheduler)
,
subscribeOn(Scheduler)
public final <R> Observable<R> switchMap(Func1<? super T,? extends Observable<? extends R>> func)
The resulting Observable completes if both the upstream Observable and the last inner Observable, if any, complete. If the upstream Observable signals an onError, the inner Observable is unsubscribed and the error delivered in-sequence.
Observable
is consumed in an
unbounded manner (i.e., without backpressure) and the inner Observable
s are expected to honor
backpressure but it is not enforced; the operator won't signal a MissingBackpressureException
but the violation may lead to OutOfMemoryError
due to internal buffer bloat.switchMap
does not operate by default on a particular Scheduler
.R
- the element type of the inner Observables and the outputfunc
- a function that, when applied to an item emitted by the source Observable, returns an
Observablefunc
to the most recently emitted item emitted by the source Observablepublic final <R> Observable<R> switchMapDelayError(Func1<? super T,? extends Observable<? extends R>> func)
The resulting Observable completes if both the upstream Observable and the last inner Observable, if any, complete. If the upstream Observable signals an onError, the termination of the last inner Observable will emit that error as is or wrapped into a CompositeException along with the other possible errors the former inner Observables signalled.
Observable
is consumed in an
unbounded manner (i.e., without backpressure) and the inner Observable
s are expected to honor
backpressure but it is not enforced; the operator won't signal a MissingBackpressureException
but the violation may lead to OutOfMemoryError
due to internal buffer bloat.switchMap
does not operate by default on a particular Scheduler
.R
- the element type of the inner Observables and the outputfunc
- a function that, when applied to an item emitted by the source Observable, returns an
Observablefunc
to the most recently emitted item emitted by the source Observablepublic final Observable<T> take(int count)
count
items emitted by the source Observable. If the source emits fewer than
count
items then all of its items are emitted.
This method returns an Observable that will invoke a subscribing Observer
's
onNext
function a maximum of count
times before invoking
onCompleted
.
Observable
's backpressure
behavior in case the first request is smaller than the count
. Otherwise, the source Observable
is consumed in an unbounded manner (i.e., without applying backpressure to it).take
does not operate by default on a particular Scheduler
.count
- the maximum number of items to emitcount
items emitted by the source Observable, or
all of the items from the source Observable if that Observable emits fewer than count
itemspublic final Observable<T> take(long time, java.util.concurrent.TimeUnit unit)
If time runs out before the Observable
completes normally, the onComplete
event will be
signaled on the default computation
Scheduler
.
Observable
's backpressure
behavior.take
operates by default on the computation
Scheduler
.time
- the length of the time windowunit
- the time unit of time
public final Observable<T> take(long time, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
If time runs out before the Observable
completes normally, the onComplete
event will be
signaled on the provided Scheduler
.
Observable
's backpressure
behavior.Scheduler
this operator will usetime
- the length of the time windowunit
- the time unit of time
scheduler
- the Scheduler used for time sourcepublic final Observable<T> takeFirst(Func1<? super T,java.lang.Boolean> predicate)
Observable
's backpressure
behavior.takeFirst
does not operate by default on a particular Scheduler
.predicate
- the condition any item emitted by the source Observable has to satisfypublic final Observable<T> takeLast(int count)
count
items emitted by the source Observable. If the source emits fewer than
count
items then all of its items are emitted.
count
is non-zero; ignores
backpressure if the count
is zero as it doesn't signal any values.takeLast
does not operate by default on a particular Scheduler
.count
- the maximum number of items to emit from the end of the sequence of items emitted by the source
Observablecount
items emitted by the source Observablejava.lang.IndexOutOfBoundsException
- if count
is less than zeropublic final Observable<T> takeLast(int count, long time, java.util.concurrent.TimeUnit unit)
Observable
in an
unbounded manner (i.e., no backpressure is applied to it).takeLast
operates by default on the computation
Scheduler
.count
- the maximum number of items to emittime
- the length of the time windowunit
- the time unit of time
count
items from the source Observable that were emitted
in a specified window of time before the Observable completedpublic final Observable<T> takeLast(int count, long time, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
Observable
in an
unbounded manner (i.e., no backpressure is applied to it).Scheduler
this operator will usecount
- the maximum number of items to emittime
- the length of the time windowunit
- the time unit of time
scheduler
- the Scheduler
that provides the timestamps for the observed itemscount
items from the source Observable that were emitted
in a specified window of time before the Observable completed, where the timing information is
provided by the given scheduler
java.lang.IndexOutOfBoundsException
- if count
is less than zeropublic final Observable<T> takeLast(long time, java.util.concurrent.TimeUnit unit)
Observable
in an
unbounded manner (i.e., no backpressure is applied to it) but note that this may
lead to OutOfMemoryError
due to internal buffer bloat.
Consider using takeLast(int, long, TimeUnit)
in this case.takeLast
operates by default on the computation
Scheduler
.time
- the length of the time windowunit
- the time unit of time
time
public final Observable<T> takeLast(long time, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
Observable
in an
unbounded manner (i.e., no backpressure is applied to it) but note that this may
lead to OutOfMemoryError
due to internal buffer bloat.
Consider using takeLast(int, long, TimeUnit, Scheduler)
in this case.Scheduler
this operator will usetime
- the length of the time windowunit
- the time unit of time
scheduler
- the Scheduler that provides the timestamps for the Observed itemstime
, where the timing information is
provided by scheduler
public final Observable<java.util.List<T>> takeLastBuffer(int count)
count
elements emitted by the
source Observable. If the source emits fewer than count
items then the emitted List will contain all of the source emissions.
Observable
in an
unbounded manner (i.e., without applying backpressure to it).takeLastBuffer
does not operate by default on a particular Scheduler
.count
- the maximum number of items to emit in the listcount
elements emitted by the
source Observablepublic final Observable<java.util.List<T>> takeLastBuffer(int count, long time, java.util.concurrent.TimeUnit unit)
count
items from the source
Observable that were emitted during a specified window of time before the source Observable completed.
Observable
in an
unbounded manner (i.e., without applying backpressure to it).takeLastBuffer
operates by default on the computation
Scheduler
.count
- the maximum number of items to emittime
- the length of the time windowunit
- the time unit of time
count
items emitted by the
source Observable during the time window defined by time
before the source Observable
completedpublic final Observable<java.util.List<T>> takeLastBuffer(int count, long time, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
count
items from the source
Observable that were emitted during a specified window of time (on a specified Scheduler) before the
source Observable completed.
Observable
in an
unbounded manner (i.e., without applying backpressure to it).Scheduler
this operator will usecount
- the maximum number of items to emittime
- the length of the time windowunit
- the time unit of time
scheduler
- the Scheduler that provides the timestamps for the observed itemscount
items emitted by the
source Observable during the time window defined by time
before the source Observable
completedpublic final Observable<java.util.List<T>> takeLastBuffer(long time, java.util.concurrent.TimeUnit unit)
Observable
in an
unbounded manner (i.e., without applying backpressure to it).takeLastBuffer
operates by default on the computation
Scheduler
.time
- the length of the time windowunit
- the time unit of time
time
before the source Observable completedpublic final Observable<java.util.List<T>> takeLastBuffer(long time, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
Observable
in an
unbounded manner (i.e., without applying backpressure to it).Scheduler
this operator will usetime
- the length of the time windowunit
- the time unit of time
scheduler
- the Scheduler that provides the timestamps for the observed itemstime
before the source Observable completed, where the
timing information is provided by scheduler
public final <E> Observable<T> takeUntil(Observable<? extends E> other)
Observable
's backpressure
behavior.takeUntil
does not operate by default on a particular Scheduler
.E
- the type of items emitted by other
other
- the Observable whose first emitted item will cause takeUntil
to stop emitting items
from the source Observableother
emits its first itempublic final Observable<T> takeWhile(Func1<? super T,java.lang.Boolean> predicate)
Observable
's backpressure
behavior.takeWhile
does not operate by default on a particular Scheduler
.predicate
- a function that evaluates an item emitted by the source Observable and returns a Booleanpredicate
, then completestakeUntil(Func1)
public final Observable<T> takeUntil(Func1<? super T,java.lang.Boolean> stopPredicate)
The difference between this operator and takeWhile(Func1)
is that here, the condition is
evaluated after the item is emitted.
takeWhile
does not operate by default on a particular Scheduler
.stopPredicate
- a function that evaluates an item emitted by the source Observable and returns a BooleantakeWhile(Func1)
public final Observable<T> throttleFirst(long windowDuration, java.util.concurrent.TimeUnit unit)
This differs from throttleLast(long, java.util.concurrent.TimeUnit)
in that this only tracks passage of time whereas
throttleLast(long, java.util.concurrent.TimeUnit)
ticks at scheduled intervals.
throttleFirst
operates by default on the computation
Scheduler
.windowDuration
- time to wait before emitting another item after emitting the last itemunit
- the unit of time of windowDuration
public final Observable<T> throttleFirst(long skipDuration, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
This differs from throttleLast(long, java.util.concurrent.TimeUnit)
in that this only tracks passage of time whereas
throttleLast(long, java.util.concurrent.TimeUnit)
ticks at scheduled intervals.
Scheduler
this operator will useskipDuration
- time to wait before emitting another item after emitting the last itemunit
- the unit of time of skipDuration
scheduler
- the Scheduler
to use internally to manage the timers that handle timeout for each
eventpublic final Observable<T> throttleLast(long intervalDuration, java.util.concurrent.TimeUnit unit)
This differs from throttleFirst(long, java.util.concurrent.TimeUnit)
in that this ticks along at a scheduled interval whereas
throttleFirst(long, java.util.concurrent.TimeUnit)
does not tick, it just tracks passage of time.
throttleLast
operates by default on the computation
Scheduler
.intervalDuration
- duration of windows within which the last item emitted by the source Observable will be
emittedunit
- the unit of time of intervalDuration
sample(long, TimeUnit)
public final Observable<T> throttleLast(long intervalDuration, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
This differs from throttleFirst(long, java.util.concurrent.TimeUnit)
in that this ticks along at a scheduled interval whereas
throttleFirst(long, java.util.concurrent.TimeUnit)
does not tick, it just tracks passage of time.
Scheduler
this operator will useintervalDuration
- duration of windows within which the last item emitted by the source Observable will be
emittedunit
- the unit of time of intervalDuration
scheduler
- the Scheduler
to use internally to manage the timers that handle timeout for each
eventsample(long, TimeUnit, Scheduler)
public final Observable<T> throttleWithTimeout(long timeout, java.util.concurrent.TimeUnit unit)
Note: If the source Observable keeps emitting items more frequently than the length of the time window then no items will be emitted by the resulting Observable.
Information on debounce vs throttle:
throttleWithTimeout
operates by default on the computation
Scheduler
.timeout
- the length of the window of time that must pass after the emission of an item from the source
Observable in which that Observable emits no items in order for the item to be emitted by the
resulting Observableunit
- the TimeUnit
of timeout
debounce(long, TimeUnit)
public final Observable<T> throttleWithTimeout(long timeout, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
Note: If the source Observable keeps emitting items more frequently than the length of the time window then no items will be emitted by the resulting Observable.
Information on debounce vs throttle:
Scheduler
this operator will usetimeout
- the length of the window of time that must pass after the emission of an item from the source
Observable in which that Observable emits no items in order for the item to be emitted by the
resulting Observableunit
- the TimeUnit
of timeout
scheduler
- the Scheduler
to use internally to manage the timers that handle the timeout for each
itemdebounce(long, TimeUnit, Scheduler)
public final Observable<TimeInterval<T>> timeInterval()
Observable
's backpressure
behavior.timeInterval
does not operate on any particular scheduler but uses the current time
from the computation
Scheduler
.public final Observable<TimeInterval<T>> timeInterval(Scheduler scheduler)
Observable
's backpressure
behavior.Scheduler
.scheduler
- the Scheduler
used to compute time intervalspublic final <U,V> Observable<T> timeout(Func0<? extends Observable<U>> firstTimeoutSelector, Func1<? super T,? extends Observable<V>> timeoutSelector)
TimeoutException
if either the first item emitted by the source Observable or any subsequent item
doesn't arrive within time windows defined by other Observables.
Observable
s
are expected to honor backpressure as well. If any of then violates this rule, it may throw an
IllegalStateException
when the Observable
completes.timeout
operates by default on the immediate
Scheduler
.U
- the first timeout value type (ignored)V
- the subsequent timeout value type (ignored)firstTimeoutSelector
- a function that returns an Observable that determines the timeout window for the first source
itemtimeoutSelector
- a function that returns an Observable for each item emitted by the source Observable 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 selectorspublic final <U,V> Observable<T> timeout(Func0<? extends Observable<U>> firstTimeoutSelector, Func1<? super T,? extends Observable<V>> timeoutSelector, Observable<? extends T> other)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.timeout
operates by default on the immediate
Scheduler
.U
- the first timeout value type (ignored)V
- the subsequent timeout value type (ignored)firstTimeoutSelector
- a function that returns an Observable which determines the timeout window for the first source
itemtimeoutSelector
- a function that returns an Observable for each item emitted by the source Observable and that
determines the timeout window in which the subsequent source item must arrive in order to
continue the sequenceother
- the fallback Observable to switch to if the source Observable times outother
Observable if
either the first item emitted by the source Observable or any subsequent item doesn't arrive
within time windows defined by the timeout selectorsjava.lang.NullPointerException
- if timeoutSelector
is nullpublic final <V> Observable<T> timeout(Func1<? super T,? extends Observable<V>> timeoutSelector)
TimeoutException
if an item emitted by the source Observable doesn't arrive within a window of
time after the emission of the previous item, where that period of time is measured by an Observable that
is a function of the previous item.
Note: The arrival of the first source item is never timed out.
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.timeout
operates by default on the immediate
Scheduler
.V
- the timeout value type (ignored)timeoutSelector
- a function that returns an observable for each item emitted by the source
Observable and that determines the timeout window for the subsequent itemTimeoutException
if an item emitted by the source Observable takes longer to arrive than
the time window defined by the selector for the previously emitted itempublic final <V> Observable<T> timeout(Func1<? super T,? extends Observable<V>> timeoutSelector, Observable<? extends T> other)
Note: The arrival of the first source item is never timed out.
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.timeout
operates by default on the immediate
Scheduler
.V
- the timeout value type (ignored)timeoutSelector
- a function that returns an Observable, for each item emitted by the source Observable, that
determines the timeout window for the subsequent itemother
- the fallback Observable to switch to if the source Observable times outpublic final Observable<T> timeout(long timeout, java.util.concurrent.TimeUnit timeUnit)
TimeoutException
.
Observable
's backpressure
behavior.timeout
operates by default on the computation
Scheduler
.timeout
- maximum duration between emitted items before a timeout occurstimeUnit
- the unit of time that applies to the timeout
argument.TimeoutException
in case of a
timeoutpublic final Observable<T> timeout(long timeout, java.util.concurrent.TimeUnit timeUnit, Observable<? extends T> other)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.timeout
operates by default on the computation
Scheduler
.timeout
- maximum duration between items before a timeout occurstimeUnit
- the unit of time that applies to the timeout
argumentother
- the fallback Observable to use in case of a timeoutpublic final Observable<T> timeout(long timeout, java.util.concurrent.TimeUnit timeUnit, Observable<? extends T> other, Scheduler scheduler)
Observable
sources are expected to honor backpressure as well.
If any of the source Observable
s violate this, it may throw an
IllegalStateException
when the source Observable
completes.Scheduler
this operator will usetimeout
- maximum duration between items before a timeout occurstimeUnit
- the unit of time that applies to the timeout
argumentother
- the Observable to use as the fallback in case of a timeoutscheduler
- the Scheduler
to run the timeout timers onpublic final Observable<T> timeout(long timeout, java.util.concurrent.TimeUnit timeUnit, Scheduler scheduler)
TimeoutException
.
Observable
's backpressure
behavior.Scheduler
this operator will usetimeout
- maximum duration between items before a timeout occurstimeUnit
- the unit of time that applies to the timeout
argumentscheduler
- the Scheduler to run the timeout timers onTimeoutException
in case of a
timeoutpublic final Observable<Timestamped<T>> timestamp()
Timestamped
object.
Observable
's backpressure
behavior.timestamp
does not operate on any particular scheduler but uses the current time
from the computation
Scheduler
.public final Observable<Timestamped<T>> timestamp(Scheduler scheduler)
Timestamped
object whose timestamps are provided by a specified Scheduler.
Observable
's backpressure
behavior.Scheduler
.scheduler
- the Scheduler
to use as a time sourcescheduler
public final BlockingObservable<T> toBlocking()
BlockingObservable
(an Observable with blocking operators).
Observable
's backpressure
behavior.toBlocking
does not operate by default on a particular Scheduler
.BlockingObservable
version of this Observablepublic final Observable<java.util.List<T>> toList()
Normally, an Observable that returns multiple items will do so by invoking its Observer
's
onNext
method for each such item. You can change this behavior, instructing the
Observable to compose a list of all of these items and then to invoke the Observer's onNext
function once, passing it the entire list, by calling the Observable's toList
method prior to
calling its subscribe()
method.
Be careful not to use this operator on Observables that emit infinite or very large numbers of items, as you do not have the option to unsubscribe.
Observable
in an
unbounded manner (i.e., without applying backpressure to it).toList
does not operate by default on a particular Scheduler
.public final <K> Observable<java.util.Map<K,T>> toMap(Func1<? super T,? 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.
Observable
in an
unbounded manner (i.e., without applying backpressure to it).toMap
does not operate by default on a particular Scheduler
.K
- the key type of the MapkeySelector
- the function that extracts the key from a source item to be used in the HashMappublic final <K,V> Observable<java.util.Map<K,V>> toMap(Func1<? super T,? extends K> keySelector, Func1<? super T,? 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.
Observable
in an
unbounded manner (i.e., without applying backpressure to it).toMap
does not operate by default on a particular Scheduler
.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 HashMappublic final <K,V> Observable<java.util.Map<K,V>> toMap(Func1<? super T,? extends K> keySelector, Func1<? super T,? extends V> valueSelector, Func0<? extends java.util.Map<K,V>> mapFactory)
mapFactory
function, that
contains keys and values extracted from the items emitted by the source Observable.
Observable
in an
unbounded manner (i.e., without applying backpressure to it).toMap
does not operate by default on a particular Scheduler
.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 MapmapFactory
- the function that returns a Map instance to be usedpublic final <K> Observable<java.util.Map<K,java.util.Collection<T>>> toMultimap(Func1<? super T,? extends K> keySelector)
keySelector
function.
toMultiMap
does not operate by default on a particular Scheduler
.K
- the key type of the MapkeySelector
- the function that extracts the key from the source items to be used as key in the HashMappublic final <K,V> Observable<java.util.Map<K,java.util.Collection<V>>> toMultimap(Func1<? super T,? extends K> keySelector, Func1<? super T,? extends V> valueSelector)
valueSelector
function from items emitted by the source Observable, keyed by a
specified keySelector
function.
Observable
in an
unbounded manner (i.e., without applying backpressure to it).toMultiMap
does not operate by default on a particular Scheduler
.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 HashMappublic final <K,V> Observable<java.util.Map<K,java.util.Collection<V>>> toMultimap(Func1<? super T,? extends K> keySelector, Func1<? super T,? extends V> valueSelector, Func0<? extends java.util.Map<K,java.util.Collection<V>>> mapFactory)
mapFactory
function, that
contains an ArrayList of values, extracted by a specified valueSelector
function from items
emitted by the source Observable and keyed by the keySelector
function.
Observable
in an
unbounded manner (i.e., without applying backpressure to it).toMultiMap
does not operate by default on a particular Scheduler
.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 MapmapFactory
- the function that returns a Map instance to be usedpublic final <K,V> Observable<java.util.Map<K,java.util.Collection<V>>> toMultimap(Func1<? super T,? extends K> keySelector, Func1<? super T,? extends V> valueSelector, Func0<? extends java.util.Map<K,java.util.Collection<V>>> mapFactory, Func1<? super K,? extends java.util.Collection<V>> collectionFactory)
mapFactory
function, that
contains a custom collection of values, extracted by a specified valueSelector
function from
items emitted by the source Observable, and keyed by the keySelector
function.
Observable
in an
unbounded manner (i.e., without applying backpressure to it).toMultiMap
does not operate by default on a particular Scheduler
.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 MapmapFactory
- 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 Mappublic final Observable<java.util.List<T>> toSortedList()
Comparable
with respect to all
other items in the sequence.
Observable
in an
unbounded manner (i.e., without applying backpressure to it).toSortedList
does not operate by default on a particular Scheduler
.java.lang.ClassCastException
- if any item emitted by the Observable does not implement Comparable
with respect to
all other items emitted by the Observablepublic final Observable<java.util.List<T>> toSortedList(Func2<? super T,? super T,java.lang.Integer> sortFunction)
Observable
in an
unbounded manner (i.e., without applying backpressure to it).toSortedList
does not operate by default on a particular Scheduler
.sortFunction
- a function that compares two items emitted by the source Observable and returns an Integer
that indicates their sort orderpublic final Observable<java.util.List<T>> toSortedList(int initialCapacity)
Comparable
with respect to all
other items in the sequence.
Observable
in an
unbounded manner (i.e., without applying backpressure to it).toSortedList
does not operate by default on a particular Scheduler
.initialCapacity
- the initial capacity of the ArrayList used to accumulate items before sortingjava.lang.ClassCastException
- if any item emitted by the Observable does not implement Comparable
with respect to
all other items emitted by the Observablepublic final Observable<java.util.List<T>> toSortedList(Func2<? super T,? super T,java.lang.Integer> sortFunction, int initialCapacity)
Observable
in an
unbounded manner (i.e., without applying backpressure to it).toSortedList
does not operate by default on a particular Scheduler
.sortFunction
- a function that compares two items emitted by the source Observable and returns an Integer
that indicates their sort orderinitialCapacity
- the initial capacity of the ArrayList used to accumulate items before sortingpublic final Observable<T> sorted()
Comparable
with respect to all
other items in the sequence.
Note that calling sorted
with long, non-terminating or infinite sources
might cause OutOfMemoryError
Observable
in an
unbounded manner (i.e., without applying backpressure to it).sorted
does not operate by default on a particular Scheduler
.java.lang.ClassCastException
- if any item emitted by the Observable does not implement Comparable
with respect to
all other items emitted by the Observablepublic final Observable<T> sorted(Func2<? super T,? super T,java.lang.Integer> sortFunction)
Note that calling sorted
with long, non-terminating or infinite sources
might cause OutOfMemoryError
Observable
in an
unbounded manner (i.e., without applying backpressure to it).sorted
does not operate by default on a particular Scheduler
.sortFunction
- a function that compares two items emitted by the source Observable and returns an Integer
that indicates their sort orderpublic final Observable<T> unsubscribeOn(Scheduler scheduler)
Scheduler
.
Observable
's backpressure
behavior.Scheduler
this operator will usescheduler
- the Scheduler
to perform unsubscription actions onScheduler
public final <U,R> Observable<R> withLatestFrom(Observable<? extends U> other, Func2<? super T,? super U,? extends R> resultSelector)
resultSelector
function only when the source Observable (this instance) emits an item.
Scheduler
.U
- the element type of the other ObservableR
- the result type of the combinationother
- the other ObservableresultSelector
- the function to call when this Observable emits an item and the other Observable has already
emitted an item, to generate the item to be emitted by the resulting ObservableresultSelector
function only when the source Observable sequence (this instance) emits an
itempublic final <T1,T2,R> Observable<R> withLatestFrom(Observable<T1> o1, Observable<T2> o2, Func3<? super T,? 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 Observable emits (and not when any of the other sources emit, unlike combineLatest). If a source doesn't produce any value and just completes, the sequence is completed immediately.
Observable
and the downstream Subscriber. The other Observable
s are consumed in an unbounded manner.Scheduler
.T1
- the first other source's value typeT2
- the second other source's value typeR
- the result value typeo1
- the first other Observableo2
- the second other Observablecombiner
- the function called with an array of values from each participating observablepublic final <T1,T2,T3,R> Observable<R> withLatestFrom(Observable<T1> o1, Observable<T2> o2, Observable<T3> o3, Func4<? super T,? 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 Observable emits (and not when any of the other sources emit, unlike combineLatest). If a source doesn't produce any value and just completes, the sequence is completed immediately.
Observable
and the downstream Subscriber. The other Observable
s are consumed in an unbounded manner.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 Observableo2
- the second other Observableo3
- the third other Observablecombiner
- the function called with an array of values from each participating observablepublic final <T1,T2,T3,T4,R> Observable<R> withLatestFrom(Observable<T1> o1, Observable<T2> o2, Observable<T3> o3, Observable<T4> o4, Func5<? super T,? 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 Observable emits (and not when any of the other sources emit, unlike combineLatest). If a source doesn't produce any value and just completes, the sequence is completed immediately.
Observable
and the downstream Subscriber. The other Observable
s are consumed in an unbounded manner.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 Observableo2
- the second other Observableo3
- the third other Observableo4
- the fourth other Observablecombiner
- the function called with an array of values from each participating observablepublic final <T1,T2,T3,T4,T5,R> Observable<R> withLatestFrom(Observable<T1> o1, Observable<T2> o2, Observable<T3> o3, Observable<T4> o4, Observable<T5> o5, Func6<? super T,? super T1,? super T2,? super T3,? super T4,? super T5,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 Observable emits (and not when any of the other sources emit, unlike combineLatest). If a source doesn't produce any value and just completes, the sequence is completed immediately.
Observable
and the downstream Subscriber. The other Observable
s are consumed in an unbounded manner.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 typeT5
- the fifth other source's value typeR
- the result value typeo1
- the first other Observableo2
- the second other Observableo3
- the third other Observableo4
- the fourth other Observableo5
- the fifth other Observablecombiner
- the function called with an array of values from each participating observablepublic final <T1,T2,T3,T4,T5,T6,R> Observable<R> withLatestFrom(Observable<T1> o1, Observable<T2> o2, Observable<T3> o3, Observable<T4> o4, Observable<T5> o5, Observable<T6> o6, Func7<? super T,? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,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 Observable emits (and not when any of the other sources emit, unlike combineLatest). If a source doesn't produce any value and just completes, the sequence is completed immediately.
Observable
and the downstream Subscriber. The other Observable
s are consumed in an unbounded manner.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 typeT5
- the fifth other source's value typeT6
- the sixth other source's value typeR
- the result value typeo1
- the first other Observableo2
- the second other Observableo3
- the third other Observableo4
- the fourth other Observableo5
- the fifth other Observableo6
- the sixth other Observablecombiner
- the function called with an array of values from each participating observablepublic final <T1,T2,T3,T4,T5,T6,T7,R> Observable<R> withLatestFrom(Observable<T1> o1, Observable<T2> o2, Observable<T3> o3, Observable<T4> o4, Observable<T5> o5, Observable<T6> o6, Observable<T7> o7, Func8<? super T,? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,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 Observable emits (and not when any of the other sources emit, unlike combineLatest). If a source doesn't produce any value and just completes, the sequence is completed immediately.
Observable
and the downstream Subscriber. The other Observable
s are consumed in an unbounded manner.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 typeT5
- the fifth other source's value typeT6
- the sixth other source's value typeT7
- the seventh other source's value typeR
- the result value typeo1
- the first other Observableo2
- the second other Observableo3
- the third other Observableo4
- the fourth other Observableo5
- the fifth other Observableo6
- the sixth other Observableo7
- the seventh other Observablecombiner
- the function called with an array of values from each participating observablepublic final <T1,T2,T3,T4,T5,T6,T7,T8,R> Observable<R> withLatestFrom(Observable<T1> o1, Observable<T2> o2, Observable<T3> o3, Observable<T4> o4, Observable<T5> o5, Observable<T6> o6, Observable<T7> o7, Observable<T8> o8, Func9<? super T,? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,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 Observable emits (and not when any of the other sources emit, unlike combineLatest). If a source doesn't produce any value and just completes, the sequence is completed immediately.
Observable
and the downstream Subscriber. The other Observable
s are consumed in an unbounded manner.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 typeT5
- the fifth other source's value typeT6
- the sixth other source's value typeT7
- the seventh other source's value typeT8
- the eighth other source's value typeR
- the result value typeo1
- the first other Observableo2
- the second other Observableo3
- the third other Observableo4
- the fourth other Observableo5
- the fifth other Observableo6
- the sixth other Observableo7
- the seventh other Observableo8
- the eighth other Observablecombiner
- the function called with an array of values from each participating observablepublic final <R> Observable<R> withLatestFrom(Observable<?>[] others, FuncN<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 Observable emits (and not when any of the other sources emit, unlike combineLatest). If a source doesn't produce any value and just completes, the sequence is completed immediately.
Observable
and the downstream Subscriber. The other Observable
s are consumed in an unbounded manner.Scheduler
.R
- the result value typeothers
- the array of other sourcescombiner
- the function called with an array of values from each participating observablepublic final <R> Observable<R> withLatestFrom(java.lang.Iterable<Observable<?>> others, FuncN<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 Observable emits (and not when any of the other sources emit, unlike combineLatest). If a source doesn't produce any value and just completes, the sequence is completed immediately.
Observable
and the downstream Subscriber. The other Observable
s are consumed in an unbounded manner.Scheduler
.R
- the result value typeothers
- the iterable of other sourcescombiner
- the function called with an array of values from each participating observablepublic final <TClosing> Observable<Observable<T>> window(Func0<? extends Observable<? extends TClosing>> closingSelector)
closingSelector
emits an item.
Observable
in an unbounded manner.
The returned Observable
doesn't support backpressure as it uses
the closingSelector
to control the creation of windows. The returned inner Observable
s honor
backpressure but have an unbounded inner buffer that may lead to OutOfMemoryError
if left unconsumed.window
does not operate by default on a particular Scheduler
.TClosing
- the element type of the boundary ObservableclosingSelector
- a Func0
that returns an Observable
that governs the boundary between windows.
When the source Observable
emits an item, window
emits the current window and begins
a new one.closingSelector
emits an itempublic final Observable<Observable<T>> window(int count)
count
items. When the source
Observable completes or encounters an error, the resulting Observable emits the current window and
propagates the notification from the source Observable.
count
elements.window
does not operate by default on a particular Scheduler
.count
- the maximum size of each window before it should be emittedcount
items from the source Observablejava.lang.IllegalArgumentException
- if either count is non-positivepublic final Observable<Observable<T>> window(int count, int skip)
skip
items, each containing no more than count
items. When
the source Observable completes or encounters an error, the resulting Observable emits the current window
and propagates the notification from the source Observable.
count
elements.window
does not operate by default on a particular Scheduler
.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 if skip
and
count
are equal this is the same operation as window(int)
.skip
items containing at most count
items
from the source Observablejava.lang.IllegalArgumentException
- if either count or skip is non-positivepublic final Observable<Observable<T>> window(long timespan, long timeshift, java.util.concurrent.TimeUnit unit)
timeshift
argument. It emits
each window after a fixed timespan, specified by the timespan
argument. When the source
Observable completes or Observable completes or encounters an error, the resulting Observable emits the
current window and propagates the notification from the source Observable.
Observable
in an unbounded manner.
The returned Observable
doesn't support backpressure as it uses
time to control the creation of windows. The returned inner Observable
s honor
backpressure but have an unbounded inner buffer that may lead to OutOfMemoryError
if left unconsumed.window
operates by default on the computation
Scheduler
.timespan
- the period of time each window collects items before it should be emittedtimeshift
- the period of time after which a new window will be createdunit
- the unit of time that applies to the timespan
and timeshift
argumentspublic final Observable<Observable<T>> window(long timespan, long timeshift, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
timeshift
argument. It emits
each window after a fixed timespan, specified by the timespan
argument. When the source
Observable completes or Observable completes or encounters an error, the resulting Observable emits the
current window and propagates the notification from the source Observable.
Observable
in an unbounded manner.
The returned Observable
doesn't support backpressure as it uses
time to control the creation of windows. The returned inner Observable
s honor
backpressure but have an unbounded inner buffer that may lead to OutOfMemoryError
if left unconsumed.Scheduler
this operator will usetimespan
- the period of time each window collects items before it should be emittedtimeshift
- the period of time after which a new window will be createdunit
- the unit of time that applies to the timespan
and timeshift
argumentsscheduler
- the Scheduler
to use when determining the end and start of a windowpublic final Observable<Observable<T>> window(long timespan, long timeshift, java.util.concurrent.TimeUnit unit, int count, Scheduler scheduler)
timeshift
argument or a maximum
size as specified by the count
argument (whichever is reached first). It emits
each window after a fixed timespan, specified by the timespan
argument. When the source
Observable completes or Observable completes or encounters an error, the resulting Observable emits the
current window and propagates the notification from the source Observable.
Observable
in an unbounded manner.
The returned Observable
doesn't support backpressure as it uses
time to control the creation of windows. The returned inner Observable
s honor
backpressure and may hold up to count
elements at most.Scheduler
this operator will usetimespan
- the period of time each window collects items before it should be emittedtimeshift
- the period of time after which a new window will be createdunit
- the unit of time that applies to the timespan
and timeshift
argumentscount
- the maximum size of each window before it should be emittedscheduler
- the Scheduler
to use when determining the end and start of a windowpublic final Observable<Observable<T>> window(long timespan, java.util.concurrent.TimeUnit unit)
timespan
argument. When the source Observable completes or encounters an error, the resulting
Observable emits the current window and propagates the notification from the source Observable.
Observable
in an unbounded manner.
The returned Observable
doesn't support backpressure as it uses
time to control the creation of windows. The returned inner Observable
s honor
backpressure and may hold up to count
elements at most.window
operates by default on the computation
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 the timespan
argumentpublic final Observable<Observable<T>> window(long timespan, java.util.concurrent.TimeUnit unit, int count)
timespan
argument or a maximum size as specified by the count
argument (whichever is
reached first). When the source Observable completes or encounters an error, the resulting Observable
emits the current window and propagates the notification from the source Observable.
Observable
in an unbounded manner.
The returned Observable
doesn't support backpressure as it uses
time to control the creation of windows. The returned inner Observable
s honor
backpressure and may hold up to count
elements at most.window
operates by default on the computation
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 the timespan
argumentcount
- the maximum size of each window before it should be emittedpublic final Observable<Observable<T>> window(long timespan, java.util.concurrent.TimeUnit unit, int count, Scheduler scheduler)
timespan
argument or a maximum size specified by the count
argument (whichever is reached
first). When the source Observable completes or encounters an error, the resulting Observable emits the
current window and propagates the notification from the source Observable.
Observable
in an unbounded manner.
The returned Observable
doesn't support backpressure as it uses
time to control the creation of windows. The returned inner Observable
s honor
backpressure and may hold up to count
elements at most.Scheduler
this operator will usetimespan
- 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 the timespan
argumentcount
- the maximum size of each window before it should be emittedscheduler
- the Scheduler
to use when determining the end and start of a windowpublic final Observable<Observable<T>> window(long timespan, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
timespan
argument. When the source Observable completes or encounters an error, the resulting
Observable emits the current window and propagates the notification from the source Observable.
Observable
in an unbounded manner.
The returned Observable
doesn't support backpressure as it uses
time to control the creation of windows. The returned inner Observable
s honor
backpressure but have an unbounded inner buffer that may lead to OutOfMemoryError
if left unconsumed.Scheduler
this operator will usetimespan
- 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 the timespan
argumentscheduler
- the Scheduler
to use when determining the end and start of a windowpublic final <TOpening,TClosing> Observable<Observable<T>> window(Observable<? extends TOpening> windowOpenings, Func1<? super TOpening,? extends Observable<? extends TClosing>> closingSelector)
windowOpenings
Observable emits an item and when the Observable returned by
closingSelector
emits an item.
windowOpenings
Observable.
The inner Observables honor backpressure and buffer everything until the associated closing
Observable signals or completes.window
does not operate by default on a particular Scheduler
.TOpening
- the element type of the window-opening ObservableTClosing
- the element type of the window-closing ObservableswindowOpenings
- an Observable that, when it emits an item, causes another window to be createdclosingSelector
- a Func1
that produces an Observable for every window created. When this Observable
emits an item, the associated window is closed and emittedpublic final <U> Observable<Observable<T>> window(Observable<U> boundary)
boundary
Observable to control data
flow. The inner Observables honor backpressure and buffer everything until the boundary signals the next element.window
does not operate by default on a particular Scheduler
.U
- the window element type (ignored)boundary
- an Observable whose emitted items close and open windowsboundary
Observablepublic final <T2,R> Observable<R> zipWith(java.lang.Iterable<? extends T2> other, Func2<? super T,? super T2,? extends R> zipFunction)
Note that the other
Iterable is evaluated as items are observed from the source Observable; it is
not pre-consumed. This allows you to zip infinite streams on either side.
interval(long, TimeUnit)
may result in MissingBackpressureException, use
one of the onBackpressureX
to handle similar, backpressure-ignoring sources.zipWith
does not operate by default on a particular Scheduler
.T2
- the type of items in the other
IterableR
- the type of items emitted by the resulting Observableother
- the Iterable sequencezipFunction
- a function that combines the pairs of items from the Observable and the Iterable to generate
the items to be emitted by the resulting Observableother
Iterable
sequence and emits the results of zipFunction
applied to these pairspublic final <T2,R> Observable<R> zipWith(Observable<? extends T2> other, Func2<? super T,? super T2,? extends R> zipFunction)
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 unsubscribing the other sources. Therefore, it
is possible those other sources will never be able to run to completion (and thus not calling
doOnCompleted()
). 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 unsubscribe B immediately. For example:
range(1, 5).doOnCompleted(action1).zipWith(range(6, 5).doOnCompleted(action2), (a, b) -> a + b)
action1
will be called but action2
won't.
doOnUnsubscribed()
as well or use using()
to do cleanup in case of completion
or unsubscription.
interval(long, TimeUnit)
may result in MissingBackpressureException, use
one of the onBackpressureX
to handle similar, backpressure-ignoring sources.zipWith
does not operate by default on a particular Scheduler
.T2
- the type of items emitted by the other
ObservableR
- the type of items emitted by the resulting Observableother
- the other ObservablezipFunction
- a function that combines the pairs of items from the two Observables to generate the items to
be emitted by the resulting Observableother
Observable
and emits the results of zipFunction
applied to these pairspublic final AssertableSubscriber<T> test()
Long.MAX_VALUE
and subscribes
it to this Observable.
test
does not operate by default on a particular Scheduler
.History: 1.2.3 - experimental
public final AssertableSubscriber<T> test(long initialRequestAmount)
initialRequest
amount upfront.test
does not operate by default on a particular Scheduler
.History: 1.2.3 - experimental
initialRequestAmount
- the amount to request from upstream upfront, non-negative (not verified)