RxJava: Functional Reactive Programming on the JVM



rx
Class Observable<T>

java.lang.Object
  extended by rx.Observable<T>
Type Parameters:
T -
Direct Known Subclasses:
BlockingObservable, ConnectableObservable, GroupedObservable, Subject

public class Observable<T>
extends java.lang.Object

The Observable interface that implements the Reactive Pattern.

It provides overloaded methods for subscribing as well as delegate methods to the various operators.

The documentation for this interface makes use of marble diagrams. The following legend explains these diagrams:

For more information see the RxJava Wiki


Constructor Summary
protected Observable()
           
protected Observable(Func1<Observer<T>,Subscription> onSubscribe)
          Construct an Observable with Function to execute when subscribed to.
 
Method Summary
 Observable<T> aggregate(Func2<T,T,T> accumulator)
           
 Observable<T> aggregate(java.lang.Object accumulator)
          Used by dynamic languages.
static
<T> Observable<T>
aggregate(Observable<T> sequence, Func2<T,T,T> accumulator)
           
static
<T> Observable<T>
aggregate(Observable<T> sequence, java.lang.Object accumulator)
          Used by dynamic languages.
static
<T,R> Observable<R>
aggregate(Observable<T> sequence, R initialValue, Func2<R,T,R> accumulator)
           
static
<T,R> Observable<R>
aggregate(Observable<T> sequence, R initialValue, java.lang.Object accumulator)
          Used by dynamic languages.
<R> Observable<R>
aggregate(R initialValue, Func2<R,T,R> accumulator)
           
<R> Observable<R>
aggregate(R initialValue, java.lang.Object accumulator)
          Used by dynamic languages.
 Observable<java.lang.Boolean> all(Func1<T,java.lang.Boolean> predicate)
          Determines whether all elements of an observable sequence satisfies a condition.
 Observable<java.lang.Boolean> all(java.lang.Object predicate)
          Determines whether all elements of an observable sequence satisfies a condition.
static
<T> Observable<java.lang.Boolean>
all(Observable<T> sequence, Func1<T,java.lang.Boolean> predicate)
          Determines whether all elements of an observable sequence satisfies a condition.
static
<T> Observable<java.lang.Boolean>
all(Observable<T> sequence, java.lang.Object predicate)
          Determines whether all elements of an observable sequence satisfies a condition.
 Observable<T> cache()
          Similar to Observable.replay() except that this auto-subscribes to the source sequence.
static
<T> Observable<T>
cache(Observable<T> that)
          Similar to Observable.replay() except that this auto-subscribes to the source sequence.
static
<T> Observable<T>
concat(Observable<T>... source)
          Combines the objects emitted by two or more Observables, and emits the result as a single Observable, by using the concat method.
static
<T> Observable<T>
create(Func1<Observer<T>,Subscription> func)
          Creates an Observable that will execute the given function when a Observer subscribes to it.
static
<T> Observable<T>
create(java.lang.Object func)
          Creates an Observable that will execute the given function when a Observer subscribes to it.
static
<T> Observable<T>
defer(Func0<Observable<T>> observableFactory)
          Returns an observable sequence that invokes the observable factory whenever a new observer subscribes.
static
<T> Observable<T>
defer(java.lang.Object observableFactory)
          Returns an observable sequence that invokes the observable factory whenever a new observer subscribes.
<T2> Observable<T2>
dematerialize()
          Dematerializes the explicit notification values of an observable sequence as implicit notifications.
static
<T> Observable<T>
dematerialize(Observable<Notification<T>> sequence)
          Dematerializes the explicit notification values of an observable sequence as implicit notifications.
static
<T> Observable<T>
empty()
          Returns an Observable that returns no data to the Observer and immediately invokes its onCompleted method.
static
<T> Observable<T>
error(java.lang.Exception exception)
          Returns an Observable that calls onError when an Observer subscribes to it.
 Observable<T> filter(Func1<T,java.lang.Boolean> predicate)
          Filters an Observable by discarding any of its emissions that do not meet some test.
 Observable<T> filter(java.lang.Object callback)
          Filters an Observable by discarding any of its emissions that do not meet some test.
static
<T> Observable<T>
filter(Observable<T> that, Func1<T,java.lang.Boolean> predicate)
          Filters an Observable by discarding any of its emissions that do not meet some test.
static
<T> Observable<T>
filter(Observable<T> that, java.lang.Object function)
          Filters an Observable by discarding any of its emissions that do not meet some test.
 Observable<T> finallyDo(Action0 action)
          Registers an action to be called when this observable calls onComplete or onError.
static
<T> Observable<T>
finallyDo(Observable<T> source, Action0 action)
          Emits the same objects as the given Observable, calling the given action when it calls onComplete or onError.
<R> Observable<R>
flatMap(Func1<T,Observable<R>> func)
          Creates a new Observable sequence by applying a function that you supply to each item in the original Observable sequence, where that function is itself an Observable that emits items, and then merges the results of that function applied to every item emitted by the original Observable, emitting these merged results as its own sequence.
<R> Observable<R>
flatMap(java.lang.Object callback)
          Creates a new Observable sequence by applying a function that you supply to each item in the original Observable sequence, where that function is itself an Observable that emits items, and then merges the results of that function applied to every item emitted by the original Observable, emitting these merged results as its own sequence.
static
<T,R> Observable<R>
flatMap(Observable<T> sequence, Func1<T,Observable<R>> func)
          Creates a new Observable sequence by applying a function that you supply to each object in the original Observable sequence, where that function is itself an Observable that emits objects, and then merges the results of that function applied to every item emitted by the original Observable, emitting these merged results as its own sequence.
static
<T,R> Observable<R>
flatMap(Observable<T> sequence, java.lang.Object func)
          Creates a new Observable sequence by applying a function that you supply to each object in the original Observable sequence, where that function is itself an Observable that emits objects, and then merges the results of that function applied to every item emitted by the original Observable, emitting these merged results as its own sequence.
static
<T> Observable<T>
from(java.util.concurrent.Future<T> future)
          Converts an Future to an Observable sequence.
static
<T> Observable<T>
from(java.util.concurrent.Future<T> future, long timeout, java.util.concurrent.TimeUnit unit)
          Converts an Future to an Observable sequence.
static
<T> Observable<T>
from(java.lang.Iterable<T> iterable)
          Converts an Iterable sequence to an Observable sequence.
static
<T> Observable<T>
from(T... items)
          Converts an Array to an Observable sequence.
<K> Observable<GroupedObservable<K,T>>
groupBy(Func1<T,K> keySelector)
          Groups the elements of an observable according to a specified key selector function and
<K,R> Observable<GroupedObservable<K,R>>
groupBy(Func1<T,K> keySelector, Func1<T,R> elementSelector)
          Groups the elements of an observable and selects the resulting elements by using a specified function.
static
<K,T> Observable<GroupedObservable<K,T>>
groupBy(Observable<T> source, Func1<T,K> keySelector)
          Groups the elements of an observable according to a specified key selector function and
static
<K,T,R> Observable<GroupedObservable<K,R>>
groupBy(Observable<T> source, Func1<T,K> keySelector, Func1<T,R> elementSelector)
          Groups the elements of an observable and selects the resulting elements by using a specified function.
static
<T> Observable<T>
just(T value)
          Returns an Observable that notifies an Observer of a single value and then completes.
<R> Observable<R>
map(Func1<T,R> func)
          Applies a function of your choosing to every item emitted by an Observable, and returns this transformation as a new Observable sequence.
<R> Observable<R>
map(java.lang.Object callback)
          Applies a function of your choosing to every item emitted by an Observable, and returns this transformation as a new Observable sequence.
static
<T,R> Observable<R>
map(Observable<T> sequence, Func1<T,R> func)
          Applies a function of your choosing to every notification emitted by an Observable, and returns this transformation as a new Observable sequence.
static
<T,R> Observable<R>
map(Observable<T> sequence, java.lang.Object func)
          Applies a function of your choosing to every notification emitted by an Observable, and returns this transformation as a new Observable sequence.
<R> Observable<R>
mapMany(Func1<T,Observable<R>> func)
          Creates a new Observable sequence by applying a function that you supply to each item in the original Observable sequence, where that function is itself an Observable that emits items, and then merges the results of that function applied to every item emitted by the original Observable, emitting these merged results as its own sequence.
<R> Observable<R>
mapMany(java.lang.Object callback)
          Creates a new Observable sequence by applying a function that you supply to each item in the original Observable sequence, where that function is itself an Observable that emits items, and then merges the results of that function applied to every item emitted by the original Observable, emitting these merged results as its own sequence.
static
<T,R> Observable<R>
mapMany(Observable<T> sequence, Func1<T,Observable<R>> func)
          Creates a new Observable sequence by applying a function that you supply to each object in the original Observable sequence, where that function is itself an Observable that emits objects, and then merges the results of that function applied to every item emitted by the original Observable, emitting these merged results as its own sequence.
static
<T,R> Observable<R>
mapMany(Observable<T> sequence, java.lang.Object func)
          Creates a new Observable sequence by applying a function that you supply to each object in the original Observable sequence, where that function is itself an Observable that emits objects, and then merges the results of that function applied to every item emitted by the original Observable, emitting these merged results as its own sequence.
 Observable<Notification<T>> materialize()
          Materializes the implicit notifications of this observable sequence as explicit notification values.
static
<T> Observable<Notification<T>>
materialize(Observable<T> sequence)
          Materializes the implicit notifications of an observable sequence as explicit notification values.
static
<T> Observable<T>
merge(java.util.List<Observable<T>> source)
          Flattens the Observable sequences from a list of Observables into one Observable sequence without any transformation.
static
<T> Observable<T>
merge(Observable<Observable<T>> source)
          Flattens the Observable sequences emitted by a sequence of Observables that are emitted by a Observable into one Observable sequence without any transformation.
static
<T> Observable<T>
merge(Observable<T>... source)
          Flattens the Observable sequences from a series of Observables into one Observable sequence without any transformation.
static
<T> Observable<T>
mergeDelayError(java.util.List<Observable<T>> source)
          Same functionality as merge except that errors received to onError will be held until all sequences have finished (onComplete/onError) before sending the error.
static
<T> Observable<T>
mergeDelayError(Observable<Observable<T>> source)
          Same functionality as merge except that errors received to onError will be held until all sequences have finished (onComplete/onError) before sending the error.
static
<T> Observable<T>
mergeDelayError(Observable<T>... source)
          Same functionality as merge except that errors received to onError will be held until all sequences have finished (onComplete/onError) before sending the error.
static
<T,R> ConnectableObservable<R>
multicast(Observable<T> source, Subject<T,R> subject)
          Returns a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.
<R> ConnectableObservable<R>
multicast(Subject<T,R> subject)
          Returns a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.
static
<T> Observable<T>
never()
          Returns an Observable that never sends any information to an Observer.
static
<T> Observable<T>
observeOn(Observable<T> source, Scheduler scheduler)
          Asynchronously notify observers on the specified scheduler.
 Observable<T> observeOn(Scheduler scheduler)
          Asynchronously notify observers on the specified scheduler.
 Observable<T> onErrorResumeNext(Func1<java.lang.Exception,Observable<T>> resumeFunction)
          Instruct an Observable to pass control to another Observable rather than calling onError if it encounters an error.
 Observable<T> onErrorResumeNext(java.lang.Object resumeFunction)
          Instruct an Observable to emit a particular item rather than calling onError if it encounters an error.
 Observable<T> onErrorResumeNext(Observable<T> resumeSequence)
          Instruct an Observable to pass control to another Observable rather than calling onError if it encounters an error.
static
<T> Observable<T>
onErrorResumeNext(Observable<T> that, Func1<java.lang.Exception,Observable<T>> resumeFunction)
          Instruct an Observable to pass control to another Observable (the return value of a function) rather than calling onError if it encounters an error.
static
<T> Observable<T>
onErrorResumeNext(Observable<T> that, java.lang.Object resumeFunction)
          Instruct an Observable to pass control to another Observable (the return value of a function) rather than calling onError if it encounters an error.
static
<T> Observable<T>
onErrorResumeNext(Observable<T> that, Observable<T> resumeSequence)
          Instruct an Observable to pass control to another Observable rather than calling onError if it encounters an error.
 Observable<T> onErrorReturn(Func1<java.lang.Exception,T> resumeFunction)
          Instruct an Observable to emit a particular item rather than calling onError if it encounters an error.
 Observable<T> onErrorReturn(java.lang.Object resumeFunction)
          Instruct an Observable to emit a particular item rather than calling onError if it encounters an error.
static
<T> Observable<T>
onErrorReturn(Observable<T> that, Func1<java.lang.Exception,T> resumeFunction)
          Instruct an Observable to emit a particular item to its Observer's onNext function rather than calling onError if it encounters an error.
 ConnectableObservable<T> publish()
          Returns a connectable observable sequence that shares a single subscription to the underlying sequence.
static
<T> ConnectableObservable<T>
publish(Observable<T> that)
          Returns a connectable observable sequence that shares a single subscription to the underlying sequence.
static Observable<java.lang.Integer> range(int start, int count)
          Generates an observable sequence of integral numbers within a specified range.
 Observable<T> reduce(Func2<T,T,T> accumulator)
          Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, 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 output.
 Observable<T> reduce(java.lang.Object accumulator)
          Used by dynamic languages.
static
<T> Observable<T>
reduce(Observable<T> sequence, Func2<T,T,T> accumulator)
          Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, 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 output.
static
<T> Observable<T>
reduce(Observable<T> sequence, java.lang.Object accumulator)
          Used by dynamic languages.
static
<T,R> Observable<R>
reduce(Observable<T> sequence, R initialValue, Func2<R,T,R> accumulator)
          Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, 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 output.
static
<T,R> Observable<R>
reduce(Observable<T> sequence, R initialValue, java.lang.Object accumulator)
          Used by dynamic languages.
<R> Observable<R>
reduce(R initialValue, Func2<R,T,R> accumulator)
          Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, 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 output.
<R> Observable<R>
reduce(R initialValue, java.lang.Object accumulator)
          Used by dynamic languages.
 ConnectableObservable<T> replay()
          Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying all notifications.
static
<T> ConnectableObservable<T>
replay(Observable<T> that)
          Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying all notifications.
 Observable<T> sample(long period, java.util.concurrent.TimeUnit unit)
          Samples the observable sequence at each interval.
 Observable<T> sample(long period, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
          Samples the observable sequence at each interval.
 Observable<T> scan(Func2<T,T,T> accumulator)
          Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, 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 result of each of these iterations.
 Observable<T> scan(java.lang.Object accumulator)
          Used by dynamic languages.
static
<T> Observable<T>
scan(Observable<T> sequence, Func2<T,T,T> accumulator)
          Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, 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 result of each of these iterations as its own sequence.
static
<T> Observable<T>
scan(Observable<T> sequence, java.lang.Object accumulator)
          Used by dynamic languages.
static
<T,R> Observable<R>
scan(Observable<T> sequence, R initialValue, Func2<R,T,R> accumulator)
          Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, 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 result of each of these iterations as its own sequence.
static
<T,R> Observable<R>
scan(Observable<T> sequence, R initialValue, java.lang.Object accumulator)
          Used by dynamic languages.
<R> Observable<R>
scan(R initialValue, Func2<R,T,R> accumulator)
          Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, 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 result of each of these iterations.
<R> Observable<R>
scan(R initialValue, java.lang.Object accumulator)
          Used by dynamic languages.
static
<T> Observable<java.lang.Boolean>
sequenceEqual(Observable<T> first, Observable<T> second)
          Determines whether two sequences are equal by comparing the elements pairwise.
static
<T> Observable<java.lang.Boolean>
sequenceEqual(Observable<T> first, Observable<T> second, Func2<T,T,java.lang.Boolean> equality)
          Determines whether two sequences are equal by comparing the elements pairwise using a specified equality function.
static
<T> Observable<java.lang.Boolean>
sequenceEqual(Observable<T> first, Observable<T> second, java.lang.Object equality)
          Determines whether two sequences are equal by comparing the elements pairwise using a specified equality function.
 Observable<T> skip(int num)
          Returns an Observable that skips the first num items emitted by the source Observable.
static
<T> Observable<T>
skip(Observable<T> items, int num)
          Returns an Observable that skips the first num items emitted by the source Observable.
 Observable<T> startWith(T... values)
           
 Subscription subscribe(Action1<T> onNext)
           
 Subscription subscribe(Action1<T> onNext, Action1<java.lang.Exception> onError)
           
 Subscription subscribe(Action1<T> onNext, Action1<java.lang.Exception> onError, Action0 onComplete)
           
 Subscription subscribe(Action1<T> onNext, Action1<java.lang.Exception> onError, Action0 onComplete, Scheduler scheduler)
           
 Subscription subscribe(Action1<T> onNext, Action1<java.lang.Exception> onError, Scheduler scheduler)
           
 Subscription subscribe(Action1<T> onNext, Scheduler scheduler)
           
 Subscription subscribe(java.util.Map<java.lang.String,java.lang.Object> callbacks)
           
 Subscription subscribe(java.util.Map<java.lang.String,java.lang.Object> callbacks, Scheduler scheduler)
           
 Subscription subscribe(java.lang.Object o)
           
 Subscription subscribe(java.lang.Object onNext, java.lang.Object onError)
           
 Subscription subscribe(java.lang.Object onNext, java.lang.Object onError, java.lang.Object onComplete)
           
 Subscription subscribe(java.lang.Object onNext, java.lang.Object onError, java.lang.Object onComplete, Scheduler scheduler)
           
 Subscription subscribe(java.lang.Object onNext, java.lang.Object onError, Scheduler scheduler)
           
 Subscription subscribe(java.lang.Object o, Scheduler scheduler)
           
 Subscription subscribe(Observer<T> observer)
          an Observer must call an Observable's subscribe method in order to register itself to receive push-based notifications from the Observable.
 Subscription subscribe(Observer<T> observer, Scheduler scheduler)
          an Observer must call an Observable's subscribe method in order to register itself to receive push-based notifications from the Observable.
static
<T> Observable<T>
subscribeOn(Observable<T> source, Scheduler scheduler)
          Asynchronously subscribes and unsubscribes observers on the specified scheduler.
 Observable<T> subscribeOn(Scheduler scheduler)
          Asynchronously subscribes and unsubscribes observers on the specified scheduler.
static
<T> Observable<T>
switchDo(Observable<Observable<T>> sequenceOfSequences)
          Accepts an Observable sequence of Observable sequences, and transforms it into a single Observable sequence, which publishes the values of the most recently published Observable sequence.
static
<T> Observable<T>
synchronize(Observable<T> observable)
          Accepts an Observable and wraps it in another Observable that ensures that the resulting Observable is chronologically well-behaved.
 Observable<T> take(int num)
          Returns an Observable that emits the first num items emitted by the source Observable.
static
<T> Observable<T>
take(Observable<T> items, int num)
          Returns an Observable that emits the first num items emitted by the source Observable.
 Observable<T> takeLast(int count)
          Returns an Observable that emits the last count items emitted by the source Observable.
static
<T> Observable<T>
takeLast(Observable<T> items, int count)
          Returns an Observable that emits the last count items emitted by the source Observable.
<E> Observable<T>
takeUntil(Observable<E> other)
          Returns the values from the source observable sequence until the other observable sequence produces a value.
static
<T,E> Observable<T>
takeUntil(Observable<T> source, Observable<E> other)
          Returns the values from the source observable sequence until the other observable sequence produces a value.
 Observable<T> takeWhile(Func1<T,java.lang.Boolean> predicate)
          Returns an Observable that items emitted by the source Observable as long as a specified condition is true.
 Observable<T> takeWhile(java.lang.Object predicate)
          Returns an Observable that items emitted by the source Observable as long as a specified condition is true.
static
<T> Observable<T>
takeWhile(Observable<T> items, Func1<T,java.lang.Boolean> predicate)
          Returns the values from the start of an observable sequence while a given predicate remains true.
static
<T> Observable<T>
takeWhile(Observable<T> items, java.lang.Object predicate)
          Returns the values from the start of an observable sequence while a given predicate remains true.
 Observable<T> takeWhileWithIndex(Func2<T,java.lang.Integer,java.lang.Boolean> predicate)
          Returns values from an observable sequence as long as a specified condition is true, and then skips the remaining values.
 Observable<T> takeWhileWithIndex(java.lang.Object predicate)
          Returns values from an observable sequence as long as a specified condition is true, and then skips the remaining values.
static
<T> Observable<T>
takeWhileWithIndex(Observable<T> items, Func2<T,java.lang.Integer,java.lang.Boolean> predicate)
          Returns values from an observable sequence as long as a specified condition is true, and then skips the remaining values.
static
<T> Observable<T>
takeWhileWithIndex(Observable<T> items, java.lang.Object predicate)
           
 Observable<Timestamped<T>> timestamp()
          Adds a timestamp to each item emitted by this observable.
 BlockingObservable<T> toBlockingObservable()
           
 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.
static
<T> Observable<java.util.List<T>>
toList(Observable<T> that)
          Returns an Observable that emits a single item, a list composed of all the items emitted by the source Observable.
static
<T> Observable<T>
toObservable(java.util.concurrent.Future<T> future)
          Deprecated. Replaced by Observable.from(Future)
static
<T> Observable<T>
toObservable(java.util.concurrent.Future<T> future, long timeout, java.util.concurrent.TimeUnit unit)
          Deprecated. Replaced by Observable.from(Future, long, TimeUnit)
static
<T> Observable<T>
toObservable(java.lang.Iterable<T> iterable)
          Converts an Iterable sequence to an Observable sequence.
static
<T> Observable<T>
toObservable(T... items)
          Deprecated. Use Observable.from(Object...)
 Observable<java.util.List<T>> toSortedList()
          Sort T objects by their natural order (object must implement Comparable).
 Observable<java.util.List<T>> toSortedList(Func2<T,T,java.lang.Integer> sortFunction)
          Sort T objects using the defined sort function.
 Observable<java.util.List<T>> toSortedList(java.lang.Object sortFunction)
          Sort T objects using the defined sort function.
static
<T> Observable<java.util.List<T>>
toSortedList(Observable<T> sequence)
          Sort T objects by their natural order (object must implement Comparable).
static
<T> Observable<java.util.List<T>>
toSortedList(Observable<T> sequence, Func2<T,T,java.lang.Integer> sortFunction)
          Sort T objects using the defined sort function.
static
<T> Observable<java.util.List<T>>
toSortedList(Observable<T> sequence, java.lang.Object sortFunction)
          Sort T objects using the defined sort function.
 Observable<T> where(Func1<T,java.lang.Boolean> predicate)
          Filters an Observable by discarding any of its emissions that do not meet some test.
static
<T> Observable<T>
where(Observable<T> that, Func1<T,java.lang.Boolean> predicate)
          Filters an Observable by discarding any of its emissions that do not meet some test.
static
<R,T0,T1> Observable<R>
zip(Observable<T0> w0, Observable<T1> w1, Func2<T0,T1,R> reduceFunction)
          Returns an Observable that applies a function of your choosing to the combination of items emitted, in sequence, by two other Observables, with the results of this function becoming the sequence emitted by the returned Observable.
static
<R,T0,T1> Observable<R>
zip(Observable<T0> w0, Observable<T1> w1, java.lang.Object function)
          Returns an Observable that applies a function of your choosing to the combination of items emitted, in sequence, by two other Observables, with the results of this function becoming the sequence emitted by the returned Observable.
static
<R,T0,T1,T2>
Observable<R>
zip(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Func3<T0,T1,T2,R> function)
          Returns an Observable that applies a function of your choosing to the combination of items emitted, in sequence, by three other Observables, with the results of this function becoming the sequence emitted by the returned Observable.
static
<R,T0,T1,T2>
Observable<R>
zip(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, java.lang.Object function)
          Returns an Observable that applies a function of your choosing to the combination of items emitted, in sequence, by three other Observables, with the results of this function becoming the sequence emitted by the returned Observable.
static
<R,T0,T1,T2,T3>
Observable<R>
zip(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Observable<T3> w3, Func4<T0,T1,T2,T3,R> reduceFunction)
          Returns an Observable that applies a function of your choosing to the combination of items emitted, in sequence, by four other Observables, with the results of this function becoming the sequence emitted by the returned Observable.
static
<R,T0,T1,T2,T3>
Observable<R>
zip(Observable<T0> w0, Observable<T1> w1, Observable<T2> w2, Observable<T3> w3, java.lang.Object function)
          Returns an Observable that applies a function of your choosing to the combination of items emitted, in sequence, by four other Observables, with the results of this function becoming the sequence emitted by the returned Observable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Observable

protected Observable()

Observable

protected Observable(Func1<Observer<T>,Subscription> onSubscribe)
Construct an Observable with Function to execute when subscribed to.

NOTE: Generally you're better off using Observable.create(Func1) to create an Observable instead of using inheritance.

Parameters:
onSubscribe - Func1 to be executed when Observable.subscribe(Observer) is called.
Method Detail

subscribe

public Subscription subscribe(Observer<T> observer)
an Observer must call an Observable's subscribe method in order to register itself to receive push-based notifications from the Observable. A typical implementation of the subscribe method does the following:

It stores a reference to the Observer in a collection object, such as a List object.

It returns a reference to the Subscription interface. This enables Observers to unsubscribe (that is, to stop receiving notifications) before the Observable has finished sending them and has called the Observer's Observer.onCompleted() method.

At any given time, a particular instance of an Observable implementation is responsible for accepting all subscriptions and notifying all subscribers. Unless the documentation for a particular Observable implementation indicates otherwise, Observers should make no assumptions about the Observable implementation, such as the order of notifications that multiple Observers will receive.

For more information see the RxJava Wiki

Parameters:
observer -
Returns:
a Subscription reference that allows observers to stop receiving notifications before the provider has finished sending them

subscribe

public Subscription subscribe(Observer<T> observer,
                              Scheduler scheduler)
an Observer must call an Observable's subscribe method in order to register itself to receive push-based notifications from the Observable. A typical implementation of the subscribe method does the following:

It stores a reference to the Observer in a collection object, such as a List object.

It returns a reference to the Subscription interface. This enables Observers to unsubscribe (that is, to stop receiving notifications) before the Observable has finished sending them and has called the Observer's Observer.onCompleted() method.

At any given time, a particular instance of an Observable implementation is responsible for accepting all subscriptions and notifying all subscribers. Unless the documentation for a particular Observable implementation indicates otherwise, Observers should make no assumptions about the Observable implementation, such as the order of notifications that multiple Observers will receive.

For more information see the RxJava Wiki

Parameters:
observer -
scheduler - The Scheduler that the sequence is subscribed to on.
Returns:
a Subscription reference that allows observers to stop receiving notifications before the provider has finished sending them

subscribe

public Subscription subscribe(java.util.Map<java.lang.String,java.lang.Object> callbacks)

subscribe

public Subscription subscribe(java.util.Map<java.lang.String,java.lang.Object> callbacks,
                              Scheduler scheduler)

subscribe

public Subscription subscribe(java.lang.Object o)

subscribe

public Subscription subscribe(java.lang.Object o,
                              Scheduler scheduler)

subscribe

public Subscription subscribe(Action1<T> onNext)

subscribe

public Subscription subscribe(Action1<T> onNext,
                              Scheduler scheduler)

subscribe

public Subscription subscribe(java.lang.Object onNext,
                              java.lang.Object onError)

subscribe

public Subscription subscribe(java.lang.Object onNext,
                              java.lang.Object onError,
                              Scheduler scheduler)

subscribe

public Subscription subscribe(Action1<T> onNext,
                              Action1<java.lang.Exception> onError)

subscribe

public Subscription subscribe(Action1<T> onNext,
                              Action1<java.lang.Exception> onError,
                              Scheduler scheduler)

subscribe

public Subscription subscribe(java.lang.Object onNext,
                              java.lang.Object onError,
                              java.lang.Object onComplete)

subscribe

public Subscription subscribe(java.lang.Object onNext,
                              java.lang.Object onError,
                              java.lang.Object onComplete,
                              Scheduler scheduler)

subscribe

public Subscription subscribe(Action1<T> onNext,
                              Action1<java.lang.Exception> onError,
                              Action0 onComplete)

subscribe

public Subscription subscribe(Action1<T> onNext,
                              Action1<java.lang.Exception> onError,
                              Action0 onComplete,
                              Scheduler scheduler)

multicast

public <R> ConnectableObservable<R> multicast(Subject<T,R> subject)
Returns a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.

Type Parameters:
R - result type
Parameters:
subject - the subject to push source elements into.
Returns:
a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.

create

public static <T> Observable<T> create(Func1<Observer<T>,Subscription> func)
Creates an Observable that will execute the given function when a Observer subscribes to it.

Write the function you pass to create so that it behaves as an Observable - calling the passed-in onNext, onError, and onCompleted methods appropriately.

A well-formed Observable must call either the Observer's onCompleted method exactly once or its onError method exactly once.

See Rx Design Guidelines (PDF) for detailed information.

Type Parameters:
T - the type emitted by the Observable sequence
Parameters:
func - a function that accepts an Observer and calls its onNext, onError, and onCompleted methods as appropriate, and returns a Subscription to allow canceling the subscription (if applicable)
Returns:
an Observable that, when an Observer subscribes to it, will execute the given function

create

public static <T> Observable<T> create(java.lang.Object func)
Creates an Observable that will execute the given function when a Observer subscribes to it.

This method accept Object to allow different languages to pass in closures using FunctionLanguageAdaptor.

Write the function you pass to create so that it behaves as an Observable - calling the passed-in onNext, onError, and onCompleted methods appropriately.

A well-formed Observable must call either the Observer's onCompleted method exactly once or its onError method exactly once.

See Rx Design Guidelines (PDF) for detailed information.

Type Parameters:
T - the type emitted by the Observable sequence
Parameters:
func - a function that accepts an Observer and calls its onNext, onError, and onCompleted methods as appropriate, and returns a Subscription to allow canceling the subscription (if applicable)
Returns:
an Observable that, when an Observer subscribes to it, will execute the given function

empty

public static <T> Observable<T> empty()
Returns an Observable that returns no data to the Observer and immediately invokes its onCompleted method.

Type Parameters:
T - the type of item emitted by the Observable
Returns:
an Observable that returns no data to the Observer and immediately invokes the Observer's onCompleted method

error

public static <T> Observable<T> error(java.lang.Exception exception)
Returns an Observable that calls onError when an Observer subscribes to it.

Type Parameters:
T - the type of object returned by the Observable
Parameters:
exception - the error to throw
Returns:
an Observable object that calls onError when an Observer subscribes

filter

public static <T> Observable<T> filter(Observable<T> that,
                                       Func1<T,java.lang.Boolean> predicate)
Filters an Observable by discarding any of its emissions that do not meet some test.

Parameters:
that - the Observable to filter
predicate - a function that evaluates the items emitted by the source Observable, returning true if they pass the filter
Returns:
an Observable that emits only those items in the original Observable that the filter evaluates as true

filter

public static <T> Observable<T> filter(Observable<T> that,
                                       java.lang.Object function)
Filters an Observable by discarding any of its emissions that do not meet some test.

Parameters:
that - the Observable to filter
function - a function that evaluates the items emitted by the source Observable, returning true if they pass the filter
Returns:
an Observable that emits only those items in the original Observable that the filter evaluates as true

where

public static <T> Observable<T> where(Observable<T> that,
                                      Func1<T,java.lang.Boolean> predicate)
Filters an Observable by discarding any of its emissions that do not meet some test.

Parameters:
that - the Observable to filter
predicate - a function that evaluates the items emitted by the source Observable, returning true if they pass the filter
Returns:
an Observable that emits only those items in the original Observable that the filter evaluates as true

from

public static <T> Observable<T> from(java.lang.Iterable<T> iterable)
Converts an Iterable sequence to an Observable sequence.

Type Parameters:
T - the type of items in the Iterable sequence and the type emitted by the resulting Observable
Parameters:
iterable - the source Iterable sequence
Returns:
an Observable that emits each item in the source Iterable sequence
See Also:
Observable.toObservable(Iterable)

from

public static <T> Observable<T> from(T... items)
Converts an Array to an Observable sequence.

Type Parameters:
T - the type of items in the Array, and the type of items emitted by the resulting Observable
Parameters:
items - the source Array
Returns:
an Observable that emits each item in the source Array
See Also:
Observable.toObservable(Object...)

range

public static Observable<java.lang.Integer> range(int start,
                                                  int count)
Generates an observable sequence of integral numbers within a specified range.

Parameters:
start - The value of the first integer in the sequence
count - The number of sequential integers to generate.
Returns:
An observable sequence that contains a range of sequential integral numbers.
See Also:
Observable.Range Method (Int32, Int32)

subscribeOn

public static <T> Observable<T> subscribeOn(Observable<T> source,
                                            Scheduler scheduler)
Asynchronously subscribes and unsubscribes observers on the specified scheduler.

Type Parameters:
T - the type of observable.
Parameters:
source - the source observable.
scheduler - the scheduler to perform subscription and unsubscription actions on.
Returns:
the source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.

observeOn

public static <T> Observable<T> observeOn(Observable<T> source,
                                          Scheduler scheduler)
Asynchronously notify observers on the specified scheduler.

Type Parameters:
T - the type of observable.
Parameters:
source - the source observable.
scheduler - the scheduler to notify observers on.
Returns:
the source sequence whose observations happen on the specified scheduler.

defer

public static <T> Observable<T> defer(Func0<Observable<T>> observableFactory)
Returns an observable sequence that invokes the observable factory whenever a new observer subscribes. The Defer operator allows you to defer or delay the creation of the sequence until the time when an observer subscribes to the sequence. This is useful to allow an observer to easily obtain an updates or refreshed version of the sequence.

Type Parameters:
T - the type of the observable.
Parameters:
observableFactory - the observable factory function to invoke for each observer that subscribes to the resulting sequence.
Returns:
the observable sequence whose observers trigger an invocation of the given observable factory function.

defer

public static <T> Observable<T> defer(java.lang.Object observableFactory)
Returns an observable sequence that invokes the observable factory whenever a new observer subscribes. The Defer operator allows you to defer or delay the creation of the sequence until the time when an observer subscribes to the sequence. This is useful to allow an observer to easily obtain an updates or refreshed version of the sequence.

Type Parameters:
T - the type of the observable.
Parameters:
observableFactory - the observable factory function to invoke for each observer that subscribes to the resulting sequence.
Returns:
the observable sequence whose observers trigger an invocation of the given observable factory function.

just

public static <T> Observable<T> just(T value)
Returns an Observable that notifies an Observer of a single value and then completes.

To convert any object into an Observable that emits that object, pass that object into the just method.

This is similar to the Observable.toObservable(java.lang.Iterable) method, except that toObservable 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 would convert the Iterable into an Observable that emits the entire Iterable as a single item.

Type Parameters:
T - the type of the value
Parameters:
value - the value to pass to the Observer's onNext method
Returns:
an Observable that notifies an Observer of a single value and then completes

map

public static <T,R> Observable<R> map(Observable<T> sequence,
                                      Func1<T,R> func)
Applies a function of your choosing to every notification emitted by an Observable, and returns this transformation as a new Observable sequence.

Type Parameters:
T - the type of items emitted by the the source Observable
R - the type of items returned by map function
Parameters:
sequence - the source Observable
func - a function to apply to each item in the sequence emitted by the source Observable
Returns:
an Observable that is the result of applying the transformation function to each item in the sequence emitted by the source Observable

map

public static <T,R> Observable<R> map(Observable<T> sequence,
                                      java.lang.Object func)
Applies a function of your choosing to every notification emitted by an Observable, and returns this transformation as a new Observable sequence.

Type Parameters:
T - the type of items emitted by the the source Observable
R - the type of items returned by map function
Parameters:
sequence - the source Observable
func - a function to apply to each item in the sequence emitted by the source Observable
Returns:
an Observable that is the result of applying the transformation function to each item in the sequence emitted by the source Observable

mapMany

public static <T,R> Observable<R> mapMany(Observable<T> sequence,
                                          Func1<T,Observable<R>> func)
Creates a new Observable sequence by applying a function that you supply to each object in the original Observable sequence, where that function is itself an Observable that emits objects, and then merges the results of that function applied to every item emitted by the original Observable, emitting these merged results as its own sequence.

Note: mapMany and flatMap are equivalent.

Type Parameters:
T - the type emitted by the source Observable
R - the type emitted by the Observables emitted by func
Parameters:
sequence - the source Observable
func - a function to apply to each item emitted by the source Observable, generating a Observable
Returns:
an Observable that emits a sequence that is the result of applying the transformation function to each item emitted by the source Observable and merging the results of the Observables obtained from this transformation
See Also:
Observable.flatMap(Observable, Func1)

mapMany

public static <T,R> Observable<R> mapMany(Observable<T> sequence,
                                          java.lang.Object func)
Creates a new Observable sequence by applying a function that you supply to each object in the original Observable sequence, where that function is itself an Observable that emits objects, and then merges the results of that function applied to every item emitted by the original Observable, emitting these merged results as its own sequence.

Type Parameters:
T - the type emitted by the source Observable
R - the type emitted by the Observables emitted by func
Parameters:
sequence - the source Observable
func - a function to apply to each item emitted by the source Observable, generating a Observable
Returns:
an Observable that emits a sequence that is the result of applying the transformation function to each item emitted by the source Observable and merging the results of the Observables obtained from this transformation

materialize

public static <T> Observable<Notification<T>> materialize(Observable<T> sequence)
Materializes the implicit notifications of an observable sequence as explicit notification values.

Parameters:
sequence - An observable sequence of elements to project.
Returns:
An observable sequence whose elements are the result of materializing the notifications of the given sequence.
See Also:
MSDN: Observable.Materialize

dematerialize

public static <T> Observable<T> dematerialize(Observable<Notification<T>> sequence)
Dematerializes the explicit notification values of an observable sequence as implicit notifications.

Parameters:
sequence - An observable sequence containing explicit notification values which have to be turned into implicit notifications.
Returns:
An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.
See Also:
MSDN: Observable.Dematerialize

merge

public static <T> Observable<T> merge(java.util.List<Observable<T>> source)
Flattens the Observable sequences from a list of Observables into one Observable sequence without any transformation. You can combine the output of multiple Observables so that they act like a single Observable, by using the merge method.

Parameters:
source - a list of Observables that emit sequences of items
Returns:
an Observable that emits a sequence of elements that are the result of flattening the output from the source list of Observables
See Also:
MSDN: Observable.Merge

merge

public static <T> Observable<T> merge(Observable<Observable<T>> source)
Flattens the Observable sequences emitted by a sequence of Observables that are emitted by a Observable into one Observable sequence without any transformation. You can combine the output of multiple Observables so that they act like a single Observable, by using the merge method.

Parameters:
source - an Observable that emits Observables
Returns:
an Observable that emits a sequence of elements that are the result of flattening the output from the Observables emitted by the source Observable
See Also:
MSDN: Observable.Merge Method

merge

public static <T> Observable<T> merge(Observable<T>... source)
Flattens the Observable sequences from a series of Observables into one Observable sequence without any transformation. You can combine the output of multiple Observables so that they act like a single Observable, by using the merge method.

Parameters:
source - a series of Observables that emit sequences of items
Returns:
an Observable that emits a sequence of elements that are the result of flattening the output from the source Observables
See Also:
MSDN: Observable.Merge Method

takeUntil

public static <T,E> Observable<T> takeUntil(Observable<T> source,
                                            Observable<E> other)
Returns the values from the source observable sequence until the other observable sequence produces a value.

Type Parameters:
T - the type of source.
E - the other type.
Parameters:
source - the source sequence to propagate elements for.
other - the observable sequence that terminates propagation of elements of the source sequence.
Returns:
An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.

concat

public static <T> Observable<T> concat(Observable<T>... source)
Combines the objects emitted by two or more Observables, and emits the result as a single Observable, by using the concat method.

Parameters:
source - a series of Observables that emit sequences of items
Returns:
an Observable that emits a sequence of elements that are the result of combining the output from the source Observables
See Also:
MSDN: Observable.Concat Method

finallyDo

public static <T> Observable<T> finallyDo(Observable<T> source,
                                          Action0 action)
Emits the same objects as the given Observable, calling the given action when it calls onComplete or onError.

Parameters:
source - an observable
action - an action to be called when the source completes or errors.
Returns:
an Observable that emits the same objects, then calls the action.
See Also:
MSDN: Observable.Finally Method

flatMap

public static <T,R> Observable<R> flatMap(Observable<T> sequence,
                                          Func1<T,Observable<R>> func)
Creates a new Observable sequence by applying a function that you supply to each object in the original Observable sequence, where that function is itself an Observable that emits objects, and then merges the results of that function applied to every item emitted by the original Observable, emitting these merged results as its own sequence.

Note: mapMany and flatMap are equivalent.

Type Parameters:
T - the type emitted by the source Observable
R - the type emitted by the Observables emitted by func
Parameters:
sequence - the source Observable
func - a function to apply to each item emitted by the source Observable, generating a Observable
Returns:
an Observable that emits a sequence that is the result of applying the transformation function to each item emitted by the source Observable and merging the results of the Observables obtained from this transformation
See Also:
Observable.mapMany(Observable, Func1)

flatMap

public static <T,R> Observable<R> flatMap(Observable<T> sequence,
                                          java.lang.Object func)
Creates a new Observable sequence by applying a function that you supply to each object in the original Observable sequence, where that function is itself an Observable that emits objects, and then merges the results of that function applied to every item emitted by the original Observable, emitting these merged results as its own sequence.

Note: mapMany and flatMap are equivalent.

Type Parameters:
T - the type emitted by the source Observable
R - the type emitted by the Observables emitted by func
Parameters:
sequence - the source Observable
func - a function to apply to each item emitted by the source Observable, generating a Observable
Returns:
an Observable that emits a sequence that is the result of applying the transformation function to each item emitted by the source Observable and merging the results of the Observables obtained from this transformation
See Also:
Observable.mapMany(Observable, Func1)

groupBy

public static <K,T,R> Observable<GroupedObservable<K,R>> groupBy(Observable<T> source,
                                                                 Func1<T,K> keySelector,
                                                                 Func1<T,R> elementSelector)
Groups the elements of an observable and selects the resulting elements by using a specified function.

Type Parameters:
K - the key type.
T - the source type.
R - the resulting observable type.
Parameters:
source - an observable whose elements to group.
keySelector - a function to extract the key for each element.
elementSelector - a function to map each source element to an element in an observable group.
Returns:
an observable of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.

groupBy

public static <K,T> Observable<GroupedObservable<K,T>> groupBy(Observable<T> source,
                                                               Func1<T,K> keySelector)
Groups the elements of an observable according to a specified key selector function and

Type Parameters:
K - the key type.
T - the source type.
Parameters:
source - an observable whose elements to group.
keySelector - a function to extract the key for each element.
Returns:
an observable of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.

mergeDelayError

public static <T> Observable<T> mergeDelayError(java.util.List<Observable<T>> source)
Same functionality as merge except that errors received to onError will be held until all sequences have finished (onComplete/onError) before sending the error.

Only the first onError received will be sent.

This enables receiving all successes from merged sequences without one onError from one sequence causing all onNext calls to be prevented.

Parameters:
source - a list of Observables that emit sequences of items
Returns:
an Observable that emits a sequence of elements that are the result of flattening the output from the source list of Observables
See Also:
MSDN: Observable.Merge Method

mergeDelayError

public static <T> Observable<T> mergeDelayError(Observable<Observable<T>> source)
Same functionality as merge except that errors received to onError will be held until all sequences have finished (onComplete/onError) before sending the error.

Only the first onError received will be sent.

This enables receiving all successes from merged sequences without one onError from one sequence causing all onNext calls to be prevented.

Parameters:
source - an Observable that emits Observables
Returns:
an Observable that emits a sequence of elements that are the result of flattening the output from the Observables emitted by the source Observable
See Also:
MSDN: Observable.Merge Method

mergeDelayError

public static <T> Observable<T> mergeDelayError(Observable<T>... source)
Same functionality as merge except that errors received to onError will be held until all sequences have finished (onComplete/onError) before sending the error.

Only the first onError received will be sent.

This enables receiving all successes from merged sequences without one onError from one sequence causing all onNext calls to be prevented.

Parameters:
source - a series of Observables that emit sequences of items
Returns:
an Observable that emits a sequence of elements that are the result of flattening the output from the source Observables
See Also:
MSDN: Observable.Merge Method

never

public static <T> Observable<T> never()
Returns an Observable that never sends any information to an Observer. This observable is useful primarily for testing purposes.

Type Parameters:
T - the type of item (not) emitted by the Observable
Returns:
an Observable that never sends any information to an Observer

onErrorResumeNext

public static <T> Observable<T> onErrorResumeNext(Observable<T> that,
                                                  Func1<java.lang.Exception,Observable<T>> resumeFunction)
Instruct an Observable to pass control to another Observable (the return value of a function) rather than calling 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 calls its Observer's onError function, and then quits without calling any more of its Observer's closures. The onErrorResumeNext method changes this behavior. If you pass a function that emits an Observable (resumeFunction) to an Observable's onErrorResumeNext method, if the original Observable encounters an error, instead of calling its Observer's onError function, it will instead relinquish control to this new Observable, which will call 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.

Parameters:
that - the source Observable
resumeFunction - a function that returns an Observable that will take over if the source Observable encounters an error
Returns:
the source Observable, with its behavior modified as described

onErrorResumeNext

public static <T> Observable<T> onErrorResumeNext(Observable<T> that,
                                                  java.lang.Object resumeFunction)
Instruct an Observable to pass control to another Observable (the return value of a function) rather than calling 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 calls its Observer's onError function, and then quits without calling any more of its Observer's closures. The onErrorResumeNext method changes this behavior. If you pass a function that emits an Observable (resumeFunction) to an Observable's onErrorResumeNext method, if the original Observable encounters an error, instead of calling its Observer's onError function, it will instead relinquish control to this new Observable, which will call 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.

Parameters:
that - the source Observable
resumeFunction - a function that returns an Observable that will take over if the source Observable encounters an error
Returns:
the source Observable, with its behavior modified as described

onErrorResumeNext

public static <T> Observable<T> onErrorResumeNext(Observable<T> that,
                                                  Observable<T> resumeSequence)
Instruct an Observable to pass control to another Observable rather than calling 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 calls its Observer's onError function, and then quits without calling any more of its Observer's closures. The onErrorResumeNext method changes this behavior. If you pass a function that emits an Observable (resumeFunction) to an Observable's onErrorResumeNext method, if the original Observable encounters an error, instead of calling its Observer's onError function, it will instead relinquish control to this new Observable, which will call 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.

Parameters:
that - the source Observable
resumeSequence - a function that returns an Observable that will take over if the source Observable encounters an error
Returns:
the source Observable, with its behavior modified as described

onErrorReturn

public static <T> Observable<T> onErrorReturn(Observable<T> that,
                                              Func1<java.lang.Exception,T> resumeFunction)
Instruct an Observable to emit a particular item to its Observer's onNext function rather than calling 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 calls its Observer's onError function, and then quits without calling any more of its Observer's closures. 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 calling its Observer's onError function, it will instead pass the return value of resumeFunction to the Observer's onNext method.

You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.

Parameters:
that - the source Observable
resumeFunction - a function that returns a value that will be passed into an Observer's onNext function if the Observable encounters an error that would otherwise cause it to call onError
Returns:
the source Observable, with its behavior modified as described

replay

public static <T> ConnectableObservable<T> replay(Observable<T> that)
Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying all notifications.

Parameters:
that - the source Observable
Returns:
a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.

cache

public static <T> Observable<T> cache(Observable<T> that)
Similar to Observable.replay() except that this auto-subscribes to the source sequence.

This is useful when returning an Observable that you wish to cache responses but can't control the subscribe/unsubscribe behavior of all the Observers.

NOTE: You sacrifice the ability to unsubscribe from the origin with this operator so be careful to not use this on infinite or very large sequences that will use up memory. This is similar to the Observable.toList() operator in this caution.

Returns:
an observable sequence that upon first subscription caches all events for subsequent subscriptions.

publish

public static <T> ConnectableObservable<T> publish(Observable<T> that)
Returns a connectable observable sequence that shares a single subscription to the underlying sequence.

Parameters:
that - the source Observable
Returns:
a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.

reduce

public static <T> Observable<T> reduce(Observable<T> sequence,
                                       Func2<T,T,T> accumulator)
Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, 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 output.

This technique, which is called "reduce" here, is sometimes called "fold," "accumulate," "compress," or "inject" in other programming contexts. Groovy, for instance, has an inject method that does a similar operation on lists.

Type Parameters:
T - the type item emitted by the source Observable
Parameters:
sequence - the source Observable
accumulator - an accumulator function to be invoked on each element from the sequence, whose result will be used in the next accumulator call (if applicable)
Returns:
an Observable that emits a single element that is the result of accumulating the output from applying the accumulator to the sequence of items emitted by the source Observable
See Also:
MSDN: Observable.Aggregate, Wikipedia: Fold (higher-order function)

reduce

public static <T> Observable<T> reduce(Observable<T> sequence,
                                       java.lang.Object accumulator)
Used by dynamic languages.

See Also:
Observable.reduce(Observable, Func2)

aggregate

public static <T> Observable<T> aggregate(Observable<T> sequence,
                                          Func2<T,T,T> accumulator)
See Also:
Observable.reduce(Observable, Func2)

aggregate

public static <T> Observable<T> aggregate(Observable<T> sequence,
                                          java.lang.Object accumulator)
Used by dynamic languages.

See Also:
Observable.reduce(Observable, Func2)

reduce

public static <T,R> Observable<R> reduce(Observable<T> sequence,
                                         R initialValue,
                                         Func2<R,T,R> accumulator)
Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, 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 output.

This technique, which is called "reduce" here, is sometimes called "fold," "accumulate," "compress," or "inject" in other programming contexts. Groovy, for instance, has an inject method that does a similar operation on lists.

Type Parameters:
T - the type item emitted by the source Observable
R - the type returned for each item of the target observable
Parameters:
sequence - the source Observable
initialValue - a seed passed into the first execution of the accumulator function
accumulator - an accumulator function to be invoked on each element from the sequence, whose result will be used in the next accumulator call (if applicable)
Returns:
an Observable that emits a single element that is the result of accumulating the output from applying the accumulator to the sequence of items emitted by the source Observable
See Also:
MSDN: Observable.Aggregate, Wikipedia: Fold (higher-order function)

reduce

public static <T,R> Observable<R> reduce(Observable<T> sequence,
                                         R initialValue,
                                         java.lang.Object accumulator)
Used by dynamic languages.

See Also:
Observable.reduce(Observable, Object, Func2)

aggregate

public static <T,R> Observable<R> aggregate(Observable<T> sequence,
                                            R initialValue,
                                            Func2<R,T,R> accumulator)
See Also:
Observable.reduce(Observable, Object, Func2)

aggregate

public static <T,R> Observable<R> aggregate(Observable<T> sequence,
                                            R initialValue,
                                            java.lang.Object accumulator)
Used by dynamic languages.

See Also:
Observable.reduce(Observable, Object, Func2)

scan

public static <T> Observable<T> scan(Observable<T> sequence,
                                     Func2<T,T,T> accumulator)
Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, 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 result of each of these iterations as its own sequence.

Type Parameters:
T - the type item emitted by the source Observable
Parameters:
sequence - the source Observable
accumulator - an accumulator function to be invoked on each element from the sequence, whose result will be emitted and used in the next accumulator call (if applicable)
Returns:
an Observable that emits a sequence of items that are the result of accumulating the output from the sequence emitted by the source Observable
See Also:
MSDN: Observable.Scan

scan

public static <T> Observable<T> scan(Observable<T> sequence,
                                     java.lang.Object accumulator)
Used by dynamic languages.

See Also:
Observable.scan(Observable, Func2)

scan

public static <T,R> Observable<R> scan(Observable<T> sequence,
                                       R initialValue,
                                       Func2<R,T,R> accumulator)
Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, 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 result of each of these iterations as its own sequence.

Type Parameters:
T - the type item emitted by the source Observable
R - the type returned for each item of the target observable
Parameters:
sequence - the source Observable
initialValue - the initial (seed) accumulator value
accumulator - an accumulator function to be invoked on each element from the sequence, whose result will be emitted and used in the next accumulator call (if applicable)
Returns:
an Observable that emits a sequence of items that are the result of accumulating the output from the sequence emitted by the source Observable
See Also:
MSDN: Observable.Scan

scan

public static <T,R> Observable<R> scan(Observable<T> sequence,
                                       R initialValue,
                                       java.lang.Object accumulator)
Used by dynamic languages.

See Also:
Observable.scan(Observable, Object, Func2)

all

public static <T> Observable<java.lang.Boolean> all(Observable<T> sequence,
                                                    Func1<T,java.lang.Boolean> predicate)
Determines whether all elements of an observable sequence satisfies a condition.

Type Parameters:
T - the type of observable.
Parameters:
sequence - an observable sequence whose elements to apply the predicate to.
predicate - a function to test each element for a condition.
Returns:
true if all elements of an observable sequence satisfies a condition; otherwise, false.

all

public static <T> Observable<java.lang.Boolean> all(Observable<T> sequence,
                                                    java.lang.Object predicate)
Determines whether all elements of an observable sequence satisfies a condition.

Type Parameters:
T - the type of observable.
Parameters:
sequence - an observable sequence whose elements to apply the predicate to.
predicate - a function to test each element for a condition.
Returns:
true if all elements of an observable sequence satisfies a condition; otherwise, false.

skip

public static <T> Observable<T> skip(Observable<T> items,
                                     int num)
Returns an Observable that skips the first num items emitted by the source Observable. You can ignore the first num items emitted by an Observable and attend only to those items that come after, by modifying the Observable with the skip method.

Parameters:
items - the source Observable
num - the number of items to skip
Returns:
an Observable that emits the same sequence of items emitted by the source Observable, except for the first num items
See Also:
MSDN: Observable.Skip Method

switchDo

public static <T> Observable<T> switchDo(Observable<Observable<T>> sequenceOfSequences)
Accepts an Observable sequence of Observable sequences, and transforms it into a single Observable sequence, which publishes the values of the most recently published Observable sequence.

Parameters:
sequenceOfSequences - the Observable sequence of Observable sequences.
Returns:
an Observable which publishes only the values of the most recently published Observable sequence.

synchronize

public static <T> Observable<T> synchronize(Observable<T> observable)
Accepts an Observable and wraps it in another Observable that ensures that the resulting Observable is chronologically well-behaved.

A well-behaved observable ensures onNext, onCompleted, or onError calls to its subscribers are not interleaved, onCompleted and onError are only called once respectively, and no onNext calls follow onCompleted and onError calls.

Type Parameters:
T - the type of item emitted by the source Observable
Parameters:
observable - the source Observable
Returns:
an Observable that is a chronologically well-behaved version of the source Observable

take

public static <T> Observable<T> take(Observable<T> items,
                                     int num)
Returns an Observable that emits the first num items emitted by the source Observable.

You can choose to pay attention only to the first num values emitted by an Observable by calling its take method. This method returns an Observable that will call a subscribing Observer's onNext function a maximum of num times before calling onCompleted.

Parameters:
items - the source Observable
num - the number of items from the start of the sequence emitted by the source Observable to emit
Returns:
an Observable that only emits the first num items emitted by the source Observable

takeLast

public static <T> Observable<T> takeLast(Observable<T> items,
                                         int count)
Returns an Observable that emits the last count items emitted by the source Observable.

Parameters:
items - the source Observable
count - the number of items from the end of the sequence emitted by the source Observable to emit
Returns:
an Observable that only emits the last count items emitted by the source Observable

takeWhile

public static <T> Observable<T> takeWhile(Observable<T> items,
                                          Func1<T,java.lang.Boolean> predicate)
Returns the values from the start of an observable sequence while a given predicate remains true.

Parameters:
items -
predicate - a function to test each source element for a condition
Returns:
the values from the start of the given sequence

takeWhile

public static <T> Observable<T> takeWhile(Observable<T> items,
                                          java.lang.Object predicate)
Returns the values from the start of an observable sequence while a given predicate remains true.

Parameters:
items -
predicate - a function to test each source element for a condition
Returns:
the values from the start of the given sequence

takeWhileWithIndex

public static <T> Observable<T> takeWhileWithIndex(Observable<T> items,
                                                   Func2<T,java.lang.Integer,java.lang.Boolean> predicate)
Returns values from an observable sequence as long as a specified condition is true, and then skips the remaining values.

Parameters:
items -
predicate - a function to test each element for a condition; the second parameter of the function represents the index of the source element; otherwise, false.
Returns:
the values from the start of the given sequence

takeWhileWithIndex

public static <T> Observable<T> takeWhileWithIndex(Observable<T> items,
                                                   java.lang.Object predicate)

timestamp

public Observable<Timestamped<T>> timestamp()
Adds a timestamp to each item emitted by this observable.

Returns:
An observable sequence of timestamped items.

toList

public static <T> Observable<java.util.List<T>> toList(Observable<T> that)
Returns an Observable that emits a single item, a list composed of all the items emitted by the source Observable.

Normally, an Observable that returns multiple items will do so by calling its Observer's onNext function for each such item. You can change this behavior, instructing the Observable to compose a list of all of these multiple items and then to call the Observer's onNext function once, passing it the entire list, by calling the Observable object's toList method prior to calling its subscribe method.

Parameters:
that - the source Observable
Returns:
an Observable that emits a single item: a List containing all of the items emitted by the source Observable

multicast

public static <T,R> ConnectableObservable<R> multicast(Observable<T> source,
                                                       Subject<T,R> subject)
Returns a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.

Type Parameters:
T - source type
R - result type
Parameters:
source - the source sequence whose elements will be pushed into the specified subject.
subject - the subject to push source elements into.
Returns:
a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.

toObservable

public static <T> Observable<T> toObservable(java.lang.Iterable<T> iterable)
Converts an Iterable sequence to an Observable sequence. Any object that supports the Iterable interface can be converted into an Observable that emits each iterable item in the object, by passing the object into the toObservable method.

Type Parameters:
T - the type of items in the iterable sequence and the type emitted by the resulting Observable
Parameters:
iterable - the source Iterable sequence
Returns:
an Observable that emits each item in the source Iterable sequence

toObservable

public static <T> Observable<T> toObservable(java.util.concurrent.Future<T> future)
Deprecated. Replaced by Observable.from(Future)

Converts an Future to an Observable sequence. Any object that supports the Future interface can be converted into an Observable that emits the return value of the get() method in the object, by passing the object into the toObservable method.

This is blocking so the Subscription returned when calling Observable.subscribe(Observer) does nothing.

Type Parameters:
T - the type of of object that the future's returns and the type emitted by the resulting Observable
Parameters:
future - the source Future
Returns:
an Observable that emits the item from the source Future

from

public static <T> Observable<T> from(java.util.concurrent.Future<T> future)
Converts an Future to an Observable sequence. Any object that supports the Future interface can be converted into an Observable that emits the return value of the get() method in the object, by passing the object into the toObservable method.

This is blocking so the Subscription returned when calling Observable.subscribe(Observer) does nothing.

Type Parameters:
T - the type of of object that the future's returns and the type emitted by the resulting Observable
Parameters:
future - the source Future
Returns:
an Observable that emits the item from the source Future

toObservable

public static <T> Observable<T> toObservable(java.util.concurrent.Future<T> future,
                                             long timeout,
                                             java.util.concurrent.TimeUnit unit)
Deprecated. Replaced by Observable.from(Future, long, TimeUnit)

Converts an Future to an Observable sequence. Any object that supports the Future interface can be converted into an Observable that emits the return value of the get() method in the object, by passing the object into the toObservable method. The subscribe method on this synchronously so the Subscription returned doesn't nothing.

This is blocking so the Subscription returned when calling Observable.subscribe(Observer) does nothing.

Type Parameters:
T - the type of of object that the future's returns and the type emitted by the resulting Observable
Parameters:
future - the source Future
timeout - the maximum time to wait
unit - the time unit of the time argument
Returns:
an Observable that emits the item from the source Future

from

public static <T> Observable<T> from(java.util.concurrent.Future<T> future,
                                     long timeout,
                                     java.util.concurrent.TimeUnit unit)
Converts an Future to an Observable sequence. Any object that supports the Future interface can be converted into an Observable that emits the return value of the get() method in the object, by passing the object into the toObservable method. The subscribe method on this synchronously so the Subscription returned doesn't nothing.

This is blocking so the Subscription returned when calling Observable.subscribe(Observer) does nothing.

Type Parameters:
T - the type of of object that the future's returns and the type emitted by the resulting Observable
Parameters:
future - the source Future
timeout - the maximum time to wait
unit - the time unit of the time argument
Returns:
an Observable that emits the item from the source Future

toObservable

public static <T> Observable<T> toObservable(T... items)
Deprecated. Use Observable.from(Object...)

Converts an Array sequence to an Observable sequence. An Array can be converted into an Observable that emits each item in the Array, by passing the Array into the toObservable method.

Type Parameters:
T - the type of items in the Array, and the type of items emitted by the resulting Observable
Parameters:
items - the source Array
Returns:
an Observable that emits each item in the source Array

toSortedList

public static <T> Observable<java.util.List<T>> toSortedList(Observable<T> sequence)
Sort T objects by their natural order (object must implement Comparable).

Parameters:
sequence -
Returns:
an observable containing the sorted list
Throws:
java.lang.ClassCastException - if T objects do not implement Comparable

toSortedList

public static <T> Observable<java.util.List<T>> toSortedList(Observable<T> sequence,
                                                             Func2<T,T,java.lang.Integer> sortFunction)
Sort T objects using the defined sort function.

Parameters:
sequence -
sortFunction -
Returns:
an observable containing the sorted list

toSortedList

public static <T> Observable<java.util.List<T>> toSortedList(Observable<T> sequence,
                                                             java.lang.Object sortFunction)
Sort T objects using the defined sort function.

Parameters:
sequence -
sortFunction -
Returns:
an observable containing the sorted list

zip

public static <R,T0,T1> Observable<R> zip(Observable<T0> w0,
                                          Observable<T1> w1,
                                          Func2<T0,T1,R> reduceFunction)
Returns an Observable that applies a function of your choosing to the combination of items emitted, in sequence, by two other Observables, with the results of this function becoming the sequence emitted by the returned Observable.

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 w0 and the first item emitted by w1; the second item emitted by the new Observable will be the result of the function applied to the second item emitted by w0 and the second item emitted by w1; and so forth.

The resulting Observable returned from zip will call onNext as many times as the number onNext calls of the source Observable with the shortest sequence.

Parameters:
w0 - one source Observable
w1 - another source Observable
reduceFunction - a function that, when applied to an item emitted by each of the source Observables, results in a value that will be emitted by the resulting Observable
Returns:
an Observable that emits the zipped results

sequenceEqual

public static <T> Observable<java.lang.Boolean> sequenceEqual(Observable<T> first,
                                                              Observable<T> second)
Determines whether two sequences are equal by comparing the elements pairwise.

Type Parameters:
T - type of sequence
Parameters:
first - observable to compare
second - observable to compare
Returns:
sequence of booleans, true if two sequences are equal by comparing the elements pairwise; otherwise, false.

sequenceEqual

public static <T> Observable<java.lang.Boolean> sequenceEqual(Observable<T> first,
                                                              Observable<T> second,
                                                              Func2<T,T,java.lang.Boolean> equality)
Determines whether two sequences are equal by comparing the elements pairwise using a specified equality function.

Type Parameters:
T - type of sequence
Parameters:
first - observable sequence to compare
second - observable sequence to compare
equality - a function used to compare elements of both sequences
Returns:
sequence of booleans, true if two sequences are equal by comparing the elements pairwise; otherwise, false.

sequenceEqual

public static <T> Observable<java.lang.Boolean> sequenceEqual(Observable<T> first,
                                                              Observable<T> second,
                                                              java.lang.Object equality)
Determines whether two sequences are equal by comparing the elements pairwise using a specified equality function.

Type Parameters:
T - type of sequence
Parameters:
first - observable sequence to compare
second - observable sequence to compare
equality - a function used to compare elements of both sequences
Returns:
sequence of booleans, true if two sequences are equal by comparing the elements pairwise; otherwise, false.

zip

public static <R,T0,T1> Observable<R> zip(Observable<T0> w0,
                                          Observable<T1> w1,
                                          java.lang.Object function)
Returns an Observable that applies a function of your choosing to the combination of items emitted, in sequence, by two other Observables, with the results of this function becoming the sequence emitted by the returned Observable.

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 w0 and the first item emitted by w1; the second item emitted by the new Observable will be the result of the function applied to the second item emitted by w0 and the second item emitted by w1; and so forth.

The resulting Observable returned from zip will call onNext as many times as the number onNext calls of the source Observable with the shortest sequence.

Parameters:
w0 - one source Observable
w1 - another source Observable
function - a function that, when applied to an item emitted by each of the source Observables, results in a value that will be emitted by the resulting Observable
Returns:
an Observable that emits the zipped results

zip

public static <R,T0,T1,T2> Observable<R> zip(Observable<T0> w0,
                                             Observable<T1> w1,
                                             Observable<T2> w2,
                                             Func3<T0,T1,T2,R> function)
Returns an Observable that applies a function of your choosing to the combination of items emitted, in sequence, by three other Observables, with the results of this function becoming the sequence emitted by the returned Observable.

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 w0, the first item emitted by w1, and the first item emitted by w2; the second item emitted by the new Observable will be the result of the function applied to the second item emitted by w0, the second item emitted by w1, and the second item emitted by w2; and so forth.

The resulting Observable returned from zip will call onNext as many times as the number onNext calls of the source Observable with the shortest sequence.

Parameters:
w0 - one source Observable
w1 - another source Observable
w2 - a third source Observable
function - a function that, when applied to an item emitted by each of the source Observables, results in a value that will be emitted by the resulting Observable
Returns:
an Observable that emits the zipped results

zip

public static <R,T0,T1,T2> Observable<R> zip(Observable<T0> w0,
                                             Observable<T1> w1,
                                             Observable<T2> w2,
                                             java.lang.Object function)
Returns an Observable that applies a function of your choosing to the combination of items emitted, in sequence, by three other Observables, with the results of this function becoming the sequence emitted by the returned Observable.

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 w0, the first item emitted by w1, and the first item emitted by w2; the second item emitted by the new Observable will be the result of the function applied to the second item emitted by w0, the second item emitted by w1, and the second item emitted by w2; and so forth.

The resulting Observable returned from zip will call onNext as many times as the number onNext calls of the source Observable with the shortest sequence.

Parameters:
w0 - one source Observable
w1 - another source Observable
w2 - a third source Observable
function - a function that, when applied to an item emitted by each of the source Observables, results in a value that will be emitted by the resulting Observable
Returns:
an Observable that emits the zipped results

zip

public static <R,T0,T1,T2,T3> Observable<R> zip(Observable<T0> w0,
                                                Observable<T1> w1,
                                                Observable<T2> w2,
                                                Observable<T3> w3,
                                                Func4<T0,T1,T2,T3,R> reduceFunction)
Returns an Observable that applies a function of your choosing to the combination of items emitted, in sequence, by four other Observables, with the results of this function becoming the sequence emitted by the returned Observable.

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 w0, the first item emitted by w1, the first item emitted by w2, and the first item emitted by w3; 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 returned from zip will call onNext as many times as the number onNext calls of the source Observable with the shortest sequence.

Parameters:
w0 - one source Observable
w1 - another source Observable
w2 - a third source Observable
w3 - a fourth source Observable
reduceFunction - a function that, when applied to an item emitted by each of the source Observables, results in a value that will be emitted by the resulting Observable
Returns:
an Observable that emits the zipped results

zip

public static <R,T0,T1,T2,T3> Observable<R> zip(Observable<T0> w0,
                                                Observable<T1> w1,
                                                Observable<T2> w2,
                                                Observable<T3> w3,
                                                java.lang.Object function)
Returns an Observable that applies a function of your choosing to the combination of items emitted, in sequence, by four other Observables, with the results of this function becoming the sequence emitted by the returned Observable.

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 w0, the first item emitted by w1, the first item emitted by w2, and the first item emitted by w3; 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 returned from zip will call onNext as many times as the number onNext calls of the source Observable with the shortest sequence.

Parameters:
w0 - one source Observable
w1 - another source Observable
w2 - a third source Observable
w3 - a fourth source Observable
function - a function that, when applied to an item emitted by each of the source Observables, results in a value that will be emitted by the resulting Observable
Returns:
an Observable that emits the zipped results

filter

public Observable<T> filter(Func1<T,java.lang.Boolean> predicate)
Filters an Observable by discarding any of its emissions that do not meet some test.

Parameters:
predicate - a function that evaluates the items emitted by the source Observable, returning true if they pass the filter
Returns:
an Observable that emits only those items in the original Observable that the filter evaluates as true

finallyDo

public Observable<T> finallyDo(Action0 action)
Registers an action to be called when this observable calls onComplete or onError.

Parameters:
action - an action to be called when this observable completes or errors.
Returns:
an Observable that emits the same objects as this observable, then calls the action.
See Also:
MSDN: Observable.Finally Method

filter

public Observable<T> filter(java.lang.Object callback)
Filters an Observable by discarding any of its emissions that do not meet some test.

Parameters:
callback - a function that evaluates the items emitted by the source Observable, returning true if they pass the filter
Returns:
an Observable that emits only those items in the original Observable that the filter evaluates as "true"

flatMap

public <R> Observable<R> flatMap(Func1<T,Observable<R>> func)
Creates a new Observable sequence by applying a function that you supply to each item in the original Observable sequence, where that function is itself an Observable that emits items, and then merges the results of that function applied to every item emitted by the original Observable, emitting these merged results as its own sequence.

Note: mapMany and flatMap are equivalent.

Parameters:
func - a function to apply to each item in the sequence, that returns an Observable.
Returns:
an Observable that emits a sequence that is the result of applying the transformation function to each item in the input sequence and merging the results of the Observables obtained from this transformation.
See Also:
Observable.mapMany(Func1)

flatMap

public <R> Observable<R> flatMap(java.lang.Object callback)
Creates a new Observable sequence by applying a function that you supply to each item in the original Observable sequence, where that function is itself an Observable that emits items, and then merges the results of that function applied to every item emitted by the original Observable, emitting these merged results as its own sequence.

Note: mapMany and flatMap are equivalent.

Parameters:
callback - a function to apply to each item in the sequence that returns an Observable.
Returns:
an Observable that emits a sequence that is the result of applying the transformation' function to each item in the input sequence and merging the results of the Observables obtained from this transformation.
See Also:
Observable.mapMany(Object)

where

public Observable<T> where(Func1<T,java.lang.Boolean> predicate)
Filters an Observable by discarding any of its emissions that do not meet some test.

Parameters:
predicate - a function that evaluates the items emitted by the source Observable, returning true if they pass the filter
Returns:
an Observable that emits only those items in the original Observable that the filter evaluates as true

map

public <R> Observable<R> map(Func1<T,R> func)
Applies a function of your choosing to every item emitted by an Observable, and returns this transformation as a new Observable sequence.

Parameters:
func - a function to apply to each item in the sequence.
Returns:
an Observable that emits a sequence that is the result of applying the transformation function to each item in the sequence emitted by the input Observable.

map

public <R> Observable<R> map(java.lang.Object callback)
Applies a function of your choosing to every item emitted by an Observable, and returns this transformation as a new Observable sequence.

Parameters:
callback - a function to apply to each item in the sequence.
Returns:
an Observable that emits a sequence that is the result of applying the transformation function to each item in the sequence emitted by the input Observable.

mapMany

public <R> Observable<R> mapMany(Func1<T,Observable<R>> func)
Creates a new Observable sequence by applying a function that you supply to each item in the original Observable sequence, where that function is itself an Observable that emits items, and then merges the results of that function applied to every item emitted by the original Observable, emitting these merged results as its own sequence.

Note: mapMany and flatMap are equivalent.

Parameters:
func - a function to apply to each item in the sequence, that returns an Observable.
Returns:
an Observable that emits a sequence that is the result of applying the transformation function to each item in the input sequence and merging the results of the Observables obtained from this transformation.
See Also:
Observable.flatMap(Func1)

mapMany

public <R> Observable<R> mapMany(java.lang.Object callback)
Creates a new Observable sequence by applying a function that you supply to each item in the original Observable sequence, where that function is itself an Observable that emits items, and then merges the results of that function applied to every item emitted by the original Observable, emitting these merged results as its own sequence.

Note: mapMany and flatMap are equivalent.

Parameters:
callback - a function to apply to each item in the sequence that returns an Observable.
Returns:
an Observable that emits a sequence that is the result of applying the transformation' function to each item in the input sequence and merging the results of the Observables obtained from this transformation.
See Also:
Observable.flatMap(Object)

materialize

public Observable<Notification<T>> materialize()
Materializes the implicit notifications of this observable sequence as explicit notification values.

Returns:
An observable sequence whose elements are the result of materializing the notifications of the given sequence.
See Also:
MSDN: Observable.materialize

subscribeOn

public Observable<T> subscribeOn(Scheduler scheduler)
Asynchronously subscribes and unsubscribes observers on the specified scheduler.

Parameters:
scheduler - the scheduler to perform subscription and unsubscription actions on.
Returns:
the source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.

observeOn

public Observable<T> observeOn(Scheduler scheduler)
Asynchronously notify observers on the specified scheduler.

Parameters:
scheduler - the scheduler to notify observers on.
Returns:
the source sequence whose observations happen on the specified scheduler.

dematerialize

public <T2> Observable<T2> dematerialize()
Dematerializes the explicit notification values of an observable sequence as implicit notifications.

Returns:
An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.
Throws:
java.lang.Exception - if attempted on Observable not of type Observable<Notification<T>>.
See Also:
MSDN: Observable.dematerialize

onErrorResumeNext

public Observable<T> onErrorResumeNext(Func1<java.lang.Exception,Observable<T>> resumeFunction)
Instruct an Observable to pass control to another Observable rather than calling 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 calls its Observer's onError function, and then quits without calling any more of its Observer's closures. The onErrorResumeNext method changes this behavior. If you pass another Observable (resumeFunction) to an Observable's onErrorResumeNext method, if the original Observable encounters an error, instead of calling its Observer's onErrort function, it will instead relinquish control to resumeFunction which will call 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.

Parameters:
resumeFunction -
Returns:
the original Observable, with appropriately modified behavior

onErrorResumeNext

public Observable<T> onErrorResumeNext(java.lang.Object resumeFunction)
Instruct an Observable to emit a particular item rather than calling 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 calls its Observer's onError function, and then quits without calling any more of its Observer's closures. The onErrorResumeNext method changes this behavior. If you pass another Observable (resumeFunction) to an Observable's onErrorResumeNext method, if the original Observable encounters an error, instead of calling its Observer's onError function, it will instead relinquish control to resumeFunction which will call 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.

Parameters:
resumeFunction -
Returns:
the original Observable with appropriately modified behavior

onErrorResumeNext

public Observable<T> onErrorResumeNext(Observable<T> resumeSequence)
Instruct an Observable to pass control to another Observable rather than calling 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 calls its Observer's onError function, and then quits without calling any more of its Observer's closures. 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 calling its Observer's onError function, it will instead relinquish control to resumeSequence which will call 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.

Parameters:
resumeSequence -
Returns:
the original Observable, with appropriately modified behavior

onErrorReturn

public Observable<T> onErrorReturn(Func1<java.lang.Exception,T> resumeFunction)
Instruct an Observable to emit a particular item rather than calling onError if it encounters an error.

By default, when an Observable encounters an error that prevents it from emitting the expected object to its Observer, the Observable calls its Observer's onError function, and then quits without calling any more of its Observer's closures. 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 calling its Observer's onError function, it will instead call pass the return value of resumeFunction to the Observer's onNext method.

You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.

Parameters:
resumeFunction -
Returns:
the original Observable with appropriately modified behavior

onErrorReturn

public Observable<T> onErrorReturn(java.lang.Object resumeFunction)
Instruct an Observable to emit a particular item rather than calling onError if it encounters an error.

By default, when an Observable encounters an error that prevents it from emitting the expected object to its Observer, the Observable calls its Observer's onError function, and then quits without calling any more of its Observer's closures. 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 calling its Observer's onError function, it will instead call pass the return value of resumeFunction to the Observer's onNext method.

You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.

Parameters:
resumeFunction -
Returns:
the original Observable with appropriately modified behavior

reduce

public Observable<T> reduce(Func2<T,T,T> accumulator)
Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, 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 output.

This technique, which is called "reduce" here, is sometimes called "fold," "accumulate," "compress," or "inject" in other programming contexts. Groovy, for instance, has an inject method that does a similar operation on lists.

Parameters:
accumulator - An accumulator function to be invoked on each element from the sequence, whose result will be used in the next accumulator call (if applicable).
Returns:
An observable sequence with a single element from the result of accumulating the output from the list of Observables.
See Also:
MSDN: Observable.Aggregate, Wikipedia: Fold (higher-order function)

replay

public ConnectableObservable<T> replay()
Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying all notifications.

Returns:
a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.

cache

public Observable<T> cache()
Similar to Observable.replay() except that this auto-subscribes to the source sequence.

This is useful when returning an Observable that you wish to cache responses but can't control the subscribe/unsubscribe behavior of all the Observers.

NOTE: You sacrifice the ability to unsubscribe from the origin with this operator so be careful to not use this on infinite or very large sequences that will use up memory. This is similar to the Observable.toList() operator in this caution.

Returns:
an observable sequence that upon first subscription caches all events for subsequent subscriptions.

publish

public ConnectableObservable<T> publish()
Returns a connectable observable sequence that shares a single subscription to the underlying sequence.

Returns:
a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.

reduce

public Observable<T> reduce(java.lang.Object accumulator)
Used by dynamic languages.

See Also:
Observable.reduce(Func2)

aggregate

public Observable<T> aggregate(Func2<T,T,T> accumulator)
See Also:
Observable.reduce(Func2)

aggregate

public Observable<T> aggregate(java.lang.Object accumulator)
Used by dynamic languages.

See Also:
Observable.reduce(Func2)

reduce

public <R> Observable<R> reduce(R initialValue,
                                Func2<R,T,R> accumulator)
Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, 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 output.

This technique, which is called "reduce" here, is sometimes called "fold," "accumulate," "compress," or "inject" in other programming contexts. Groovy, for instance, has an inject method that does a similar operation on lists.

Parameters:
initialValue - The initial (seed) accumulator value.
accumulator - An accumulator function to be invoked on each element from the sequence, whose result will be used in the next accumulator call (if applicable).
Returns:
an Observable that emits a single element from the result of accumulating the output from the list of Observables.
See Also:
MSDN: Observable.Aggregate, Wikipedia: Fold (higher-order function)

reduce

public <R> Observable<R> reduce(R initialValue,
                                java.lang.Object accumulator)
Used by dynamic languages.

See Also:
Observable.reduce(Object, Func2)

aggregate

public <R> Observable<R> aggregate(R initialValue,
                                   Func2<R,T,R> accumulator)
See Also:
Observable.reduce(Object, Func2)

aggregate

public <R> Observable<R> aggregate(R initialValue,
                                   java.lang.Object accumulator)
Used by dynamic languages.

See Also:
Observable.reduce(Object, Func2)

scan

public Observable<T> scan(Func2<T,T,T> accumulator)
Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, 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 result of each of these iterations. It emits the result of each of these iterations as a sequence from the returned Observable. This sort of function is sometimes called an accumulator.

Parameters:
accumulator - An accumulator function to be invoked on each element from the sequence whose result will be sent via onNext and used in the next accumulator call (if applicable).
Returns:
an Observable sequence whose elements are the result of accumulating the output from the list of Observables.
See Also:
MSDN: Observable.Scan

sample

public Observable<T> sample(long period,
                            java.util.concurrent.TimeUnit unit)
Samples the observable sequence at each interval.

Parameters:
period - The period of time that defines the sampling rate.
unit - The time unit for the sampling rate time period.
Returns:
An observable sequence whose elements are the results of sampling the current observable sequence.

sample

public Observable<T> sample(long period,
                            java.util.concurrent.TimeUnit unit,
                            Scheduler scheduler)
Samples the observable sequence at each interval.

Parameters:
period - The period of time that defines the sampling rate.
unit - The time unit for the sampling rate time period.
scheduler - The scheduler to use for sampling.
Returns:
An observable sequence whose elements are the results of sampling the current observable sequence.

scan

public Observable<T> scan(java.lang.Object accumulator)
Used by dynamic languages.

See Also:
Observable.scan(Func2)

scan

public <R> Observable<R> scan(R initialValue,
                              Func2<R,T,R> accumulator)
Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, 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 result of each of these iterations. This sort of function is sometimes called an accumulator.

Parameters:
initialValue - The initial (seed) accumulator value.
accumulator - An accumulator function to be invoked on each element from the sequence whose result will be sent via onNext and used in the next accumulator call (if applicable).
Returns:
an Observable sequence whose elements are the result of accumulating the output from the list of Observables.
See Also:
MSDN: Observable.Scan

scan

public <R> Observable<R> scan(R initialValue,
                              java.lang.Object accumulator)
Used by dynamic languages.

See Also:
Observable.scan(Object, Func2)

all

public Observable<java.lang.Boolean> all(Func1<T,java.lang.Boolean> predicate)
Determines whether all elements of an observable sequence satisfies a condition.

Parameters:
predicate - a function to test each element for a condition.
Returns:
true if all elements of an observable sequence satisfies a condition; otherwise, false.

all

public Observable<java.lang.Boolean> all(java.lang.Object predicate)
Determines whether all elements of an observable sequence satisfies a condition.

Parameters:
predicate - a function to test each element for a condition.
Returns:
true if all elements of an observable sequence satisfies a condition; otherwise, false.

skip

public Observable<T> skip(int num)
Returns an Observable that skips the first num items emitted by the source Observable. You can ignore the first num items emitted by an Observable and attend only to those items that come after, by modifying the Observable with the skip method.

Parameters:
num - The number of items to skip
Returns:
an Observable sequence that is identical to the source Observable except that it does not emit the first num items from that sequence.

take

public Observable<T> take(int num)
Returns an Observable that emits the first num items emitted by the source Observable. You can choose to pay attention only to the first num values emitted by a Observable by calling its take method. This method returns an Observable that will call a subscribing Observer's onNext function a maximum of num times before calling onCompleted.

Parameters:
num -
Returns:
an Observable that emits only the first num items from the source Observable, or all of the items from the source Observable if that Observable emits fewer than num items.

takeWhile

public Observable<T> takeWhile(Func1<T,java.lang.Boolean> predicate)
Returns an Observable that items emitted by the source Observable as long as a specified condition is true.

Parameters:
predicate - a function to test each source element for a condition
Returns:
the values from the start of the given sequence

takeWhile

public Observable<T> takeWhile(java.lang.Object predicate)
Returns an Observable that items emitted by the source Observable as long as a specified condition is true.

Parameters:
predicate - a function to test each source element for a condition
Returns:
the values from the start of the given sequence

takeWhileWithIndex

public Observable<T> takeWhileWithIndex(Func2<T,java.lang.Integer,java.lang.Boolean> predicate)
Returns values from an observable sequence as long as a specified condition is true, and then skips the remaining values.

Parameters:
predicate - a function to test each element for a condition; the second parameter of the function represents the index of the source element; otherwise, false.
Returns:
the values from the start of the given sequence

takeWhileWithIndex

public Observable<T> takeWhileWithIndex(java.lang.Object predicate)
Returns values from an observable sequence as long as a specified condition is true, and then skips the remaining values.

Parameters:
predicate - a function to test each element for a condition; the second parameter of the function represents the index of the source element; otherwise, false.
Returns:
the values from the start of the given sequence

takeLast

public Observable<T> takeLast(int count)
Returns an Observable that emits the last count items emitted by the source Observable.

Parameters:
count - the number of items from the end of the sequence emitted by the source Observable to emit
Returns:
an Observable that only emits the last count items emitted by the source Observable

takeUntil

public <E> Observable<T> takeUntil(Observable<E> other)
Returns the values from the source observable sequence until the other observable sequence produces a value.

Type Parameters:
E - the other type.
Parameters:
other - the observable sequence that terminates propagation of elements of the source sequence.
Returns:
An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.

toList

public 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. Normally, an Observable that returns multiple items will do so by calling its Observer's onNext function for each such item. You can change this behavior, instructing the Observable to compose a list of all of these multiple items and then to call the Observer's onNext function once, passing it the entire list, by calling the Observable object's toList method prior to calling its subscribe method.

Returns:
an Observable that emits a single item: a List containing all of the items emitted by the source Observable.

toSortedList

public Observable<java.util.List<T>> toSortedList()
Sort T objects by their natural order (object must implement Comparable).

Returns:
an observable containing the sorted list
Throws:
java.lang.ClassCastException - if T objects do not implement Comparable

toSortedList

public Observable<java.util.List<T>> toSortedList(Func2<T,T,java.lang.Integer> sortFunction)
Sort T objects using the defined sort function.

Parameters:
sortFunction -
Returns:
an observable containing the sorted list

toSortedList

public Observable<java.util.List<T>> toSortedList(java.lang.Object sortFunction)
Sort T objects using the defined sort function.

Parameters:
sortFunction -
Returns:
an observable containing the sorted list

startWith

public Observable<T> startWith(T... values)

groupBy

public <K,R> Observable<GroupedObservable<K,R>> groupBy(Func1<T,K> keySelector,
                                                        Func1<T,R> elementSelector)
Groups the elements of an observable and selects the resulting elements by using a specified function.

Type Parameters:
K - the key type.
R - the resulting observable type.
Parameters:
keySelector - a function to extract the key for each element.
elementSelector - a function to map each source element to an element in an observable group.
Returns:
an observable of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.

groupBy

public <K> Observable<GroupedObservable<K,T>> groupBy(Func1<T,K> keySelector)
Groups the elements of an observable according to a specified key selector function and

Type Parameters:
K - the key type.
Parameters:
keySelector - a function to extract the key for each element.
Returns:
an observable of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.

toBlockingObservable

public BlockingObservable<T> toBlockingObservable()