
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectrx.Observable<T>
T - public class Observable<T>
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
|
aggregate(Observable<T> sequence,
Func2<T,T,T> accumulator)
|
|
static
|
aggregate(Observable<T> sequence,
java.lang.Object accumulator)
Used by dynamic languages. |
|
static
|
aggregate(Observable<T> sequence,
R initialValue,
Func2<R,T,R> accumulator)
|
|
static
|
aggregate(Observable<T> sequence,
R initialValue,
java.lang.Object accumulator)
Used by dynamic languages. |
|
|
aggregate(R initialValue,
Func2<R,T,R> accumulator)
|
|
|
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
|
all(Observable<T> sequence,
Func1<T,java.lang.Boolean> predicate)
Determines whether all elements of an observable sequence satisfies a condition. |
|
static
|
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
|
cache(Observable<T> that)
Similar to Observable.replay() except that this auto-subscribes to the source sequence. |
|
static
|
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
|
create(Func1<Observer<T>,Subscription> func)
Creates an Observable that will execute the given function when a Observer subscribes to it. |
|
static
|
create(java.lang.Object func)
Creates an Observable that will execute the given function when a Observer subscribes to it. |
|
static
|
defer(Func0<Observable<T>> observableFactory)
Returns an observable sequence that invokes the observable factory whenever a new observer subscribes. |
|
static
|
defer(java.lang.Object observableFactory)
Returns an observable sequence that invokes the observable factory whenever a new observer subscribes. |
|
|
dematerialize()
Dematerializes the explicit notification values of an observable sequence as implicit notifications. |
|
static
|
dematerialize(Observable<Notification<T>> sequence)
Dematerializes the explicit notification values of an observable sequence as implicit notifications. |
|
static
|
empty()
Returns an Observable that returns no data to the Observer and immediately invokes its onCompleted method. |
|
static
|
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
|
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
|
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
|
finallyDo(Observable<T> source,
Action0 action)
Emits the same objects as the given Observable, calling the given action when it calls onComplete or onError. |
|
|
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. |
|
|
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
|
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
|
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
|
from(java.util.concurrent.Future<T> future)
Converts an Future to an Observable sequence. |
|
static
|
from(java.util.concurrent.Future<T> future,
long timeout,
java.util.concurrent.TimeUnit unit)
Converts an Future to an Observable sequence. |
|
static
|
from(java.lang.Iterable<T> iterable)
Converts an Iterable sequence to an Observable sequence. |
|
static
|
from(T... items)
Converts an Array to an Observable sequence. |
|
|
groupBy(Func1<T,K> keySelector)
Groups the elements of an observable according to a specified key selector function and |
|
|
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
|
groupBy(Observable<T> source,
Func1<T,K> keySelector)
Groups the elements of an observable according to a specified key selector function and |
|
static
|
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
|
just(T value)
Returns an Observable that notifies an Observer of a single value and then completes. |
|
|
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. |
|
|
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
|
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
|
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. |
|
|
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. |
|
|
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
|
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
|
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
|
materialize(Observable<T> sequence)
Materializes the implicit notifications of an observable sequence as explicit notification values. |
|
static
|
merge(java.util.List<Observable<T>> source)
Flattens the Observable sequences from a list of Observables into one Observable sequence without any transformation. |
|
static
|
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
|
merge(Observable<T>... source)
Flattens the Observable sequences from a series of Observables into one Observable sequence without any transformation. |
|
static
|
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
|
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
|
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
|
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. |
|
|
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
|
never()
Returns an Observable that never sends any information to an Observer. |
|
static
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
reduce(Observable<T> sequence,
java.lang.Object accumulator)
Used by dynamic languages. |
|
static
|
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
|
reduce(Observable<T> sequence,
R initialValue,
java.lang.Object accumulator)
Used by dynamic languages. |
|
|
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. |
|
|
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
|
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
|
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
|
scan(Observable<T> sequence,
java.lang.Object accumulator)
Used by dynamic languages. |
|
static
|
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
|
scan(Observable<T> sequence,
R initialValue,
java.lang.Object accumulator)
Used by dynamic languages. |
|
|
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. |
|
|
scan(R initialValue,
java.lang.Object accumulator)
Used by dynamic languages. |
|
static
|
sequenceEqual(Observable<T> first,
Observable<T> second)
Determines whether two sequences are equal by comparing the elements pairwise. |
|
static
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
takeLast(Observable<T> items,
int count)
Returns an Observable that emits the last count items emitted by the source
Observable. |
|
|
takeUntil(Observable<E> other)
Returns the values from the source observable sequence until the other observable sequence produces a value. |
|
static
|
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
|
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
|
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
|
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
|
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
|
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
|
toObservable(java.util.concurrent.Future<T> future)
Deprecated. Replaced by Observable.from(Future) |
|
static
|
toObservable(java.util.concurrent.Future<T> future,
long timeout,
java.util.concurrent.TimeUnit unit)
Deprecated. Replaced by Observable.from(Future, long, TimeUnit) |
|
static
|
toObservable(java.lang.Iterable<T> iterable)
Converts an Iterable sequence to an Observable sequence. |
|
static
|
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
|
toSortedList(Observable<T> sequence)
Sort T objects by their natural order (object must implement Comparable). |
|
static
|
toSortedList(Observable<T> sequence,
Func2<T,T,java.lang.Integer> sortFunction)
Sort T objects using the defined sort function. |
|
static
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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 |
|---|
protected Observable()
protected Observable(Func1<Observer<T>,Subscription> onSubscribe)
NOTE: Generally you're better off using Observable.create(Func1) to create an Observable instead of using inheritance.
onSubscribe - Func1 to be executed when Observable.subscribe(Observer) is called.| Method Detail |
|---|
public Subscription subscribe(Observer<T> observer)
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
observer -
Subscription reference that allows observers
to stop receiving notifications before the provider has finished sending them
public Subscription subscribe(Observer<T> observer,
Scheduler scheduler)
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
observer - scheduler - The Scheduler that the sequence is subscribed to on.
Subscription reference that allows observers
to stop receiving notifications before the provider has finished sending thempublic Subscription subscribe(java.util.Map<java.lang.String,java.lang.Object> callbacks)
public Subscription subscribe(java.util.Map<java.lang.String,java.lang.Object> callbacks,
Scheduler scheduler)
public Subscription subscribe(java.lang.Object o)
public Subscription subscribe(java.lang.Object o,
Scheduler scheduler)
public Subscription subscribe(Action1<T> onNext)
public Subscription subscribe(Action1<T> onNext,
Scheduler scheduler)
public Subscription subscribe(java.lang.Object onNext,
java.lang.Object onError)
public Subscription subscribe(java.lang.Object onNext,
java.lang.Object onError,
Scheduler scheduler)
public Subscription subscribe(Action1<T> onNext,
Action1<java.lang.Exception> onError)
public Subscription subscribe(Action1<T> onNext,
Action1<java.lang.Exception> onError,
Scheduler scheduler)
public Subscription subscribe(java.lang.Object onNext,
java.lang.Object onError,
java.lang.Object onComplete)
public Subscription subscribe(java.lang.Object onNext,
java.lang.Object onError,
java.lang.Object onComplete,
Scheduler scheduler)
public Subscription subscribe(Action1<T> onNext,
Action1<java.lang.Exception> onError,
Action0 onComplete)
public Subscription subscribe(Action1<T> onNext,
Action1<java.lang.Exception> onError,
Action0 onComplete,
Scheduler scheduler)
public <R> ConnectableObservable<R> multicast(Subject<T,R> subject)
R - result typesubject - the subject to push source elements into.
public static <T> Observable<T> create(Func1<Observer<T>,Subscription> func)
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.
T - the type emitted by the Observable sequencefunc - 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)
Observer subscribes to it, will execute the given functionpublic static <T> Observable<T> create(java.lang.Object func)
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.
T - the type emitted by the Observable sequencefunc - 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)
Observer subscribes to it, will execute the given functionpublic static <T> Observable<T> empty()
Observer and immediately invokes its onCompleted method.
T - the type of item emitted by the Observable
Observer and immediately invokes the Observer's onCompleted methodpublic static <T> Observable<T> error(java.lang.Exception exception)
onError when an Observer subscribes to it.
T - the type of object returned by the Observableexception - the error to throw
onError when an Observer subscribes
public static <T> Observable<T> filter(Observable<T> that,
Func1<T,java.lang.Boolean> predicate)
that - the Observable to filterpredicate - a function that evaluates the items emitted by the source Observable, returning true if they pass the filter
public static <T> Observable<T> filter(Observable<T> that,
java.lang.Object function)
that - the Observable to filterfunction - a function that evaluates the items emitted by the source Observable, returning true if they pass the filter
public static <T> Observable<T> where(Observable<T> that,
Func1<T,java.lang.Boolean> predicate)
that - the Observable to filterpredicate - a function that evaluates the items emitted by the source Observable, returning true if they pass the filter
public static <T> Observable<T> from(java.lang.Iterable<T> iterable)
Iterable sequence to an Observable sequence.
T - the type of items in the Iterable sequence and the type emitted by the resulting Observableiterable - the source Iterable sequence
Iterable sequenceObservable.toObservable(Iterable)public static <T> Observable<T> from(T... items)
T - the type of items in the Array, and the type of items emitted by the resulting Observableitems - the source Array
Observable.toObservable(Object...)
public static Observable<java.lang.Integer> range(int start,
int count)
start - The value of the first integer in the sequencecount - The number of sequential integers to generate.
public static <T> Observable<T> subscribeOn(Observable<T> source,
Scheduler scheduler)
T - the type of observable.source - the source observable.scheduler - the scheduler to perform subscription and unsubscription actions on.
public static <T> Observable<T> observeOn(Observable<T> source,
Scheduler scheduler)
T - the type of observable.source - the source observable.scheduler - the scheduler to notify observers on.
public static <T> Observable<T> defer(Func0<Observable<T>> observableFactory)
T - the type of the observable.observableFactory - the observable factory function to invoke for each observer that subscribes to the resulting sequence.
public static <T> Observable<T> defer(java.lang.Object observableFactory)
T - the type of the observable.observableFactory - the observable factory function to invoke for each observer that subscribes to the resulting sequence.
public static <T> Observable<T> just(T value)
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.
T - the type of the valuevalue - the value to pass to the Observer's onNext method
Observer of a single value and then completes
public static <T,R> Observable<R> map(Observable<T> sequence,
Func1<T,R> func)
T - the type of items emitted by the the source ObservableR - the type of items returned by map functionsequence - the source Observablefunc - a function to apply to each item in the sequence emitted by the source Observable
public static <T,R> Observable<R> map(Observable<T> sequence,
java.lang.Object func)
T - the type of items emitted by the the source ObservableR - the type of items returned by map functionsequence - the source Observablefunc - a function to apply to each item in the sequence emitted by the source Observable
public static <T,R> Observable<R> mapMany(Observable<T> sequence,
Func1<T,Observable<R>> func)
Note: mapMany and flatMap are equivalent.
T - the type emitted by the source ObservableR - the type emitted by the Observables emitted by funcsequence - the source Observablefunc - a function to apply to each item emitted by the source Observable, generating a
Observable
Observable.flatMap(Observable, Func1)
public static <T,R> Observable<R> mapMany(Observable<T> sequence,
java.lang.Object func)
T - the type emitted by the source ObservableR - the type emitted by the Observables emitted by funcsequence - the source Observablefunc - a function to apply to each item emitted by the source Observable, generating a
Observable
public static <T> Observable<Notification<T>> materialize(Observable<T> sequence)
sequence - An observable sequence of elements to project.
public static <T> Observable<T> dematerialize(Observable<Notification<T>> sequence)
sequence - An observable sequence containing explicit notification values which have to be turned into implicit notifications.
public static <T> Observable<T> merge(java.util.List<Observable<T>> source)
merge method.
source - a list of Observables that emit sequences of items
source list of Observablespublic static <T> Observable<T> merge(Observable<Observable<T>> source)
merge method.
source - an Observable that emits Observables
source Observablepublic static <T> Observable<T> merge(Observable<T>... source)
merge method.
source - a series of Observables that emit sequences of items
source Observables
public static <T,E> Observable<T> takeUntil(Observable<T> source,
Observable<E> other)
T - the type of source.E - the other type.source - the source sequence to propagate elements for.other - the observable sequence that terminates propagation of elements of the source sequence.
public static <T> Observable<T> concat(Observable<T>... source)
concat method.
source - a series of Observables that emit sequences of items
source Observables
public static <T> Observable<T> finallyDo(Observable<T> source,
Action0 action)
onComplete or onError.
source - an observableaction - an action to be called when the source completes or errors.
public static <T,R> Observable<R> flatMap(Observable<T> sequence,
Func1<T,Observable<R>> func)
Note: mapMany and flatMap are equivalent.
T - the type emitted by the source ObservableR - the type emitted by the Observables emitted by funcsequence - the source Observablefunc - a function to apply to each item emitted by the source Observable, generating a
Observable
Observable.mapMany(Observable, Func1)
public static <T,R> Observable<R> flatMap(Observable<T> sequence,
java.lang.Object func)
Note: mapMany and flatMap are equivalent.
T - the type emitted by the source ObservableR - the type emitted by the Observables emitted by funcsequence - the source Observablefunc - a function to apply to each item emitted by the source Observable, generating a
Observable
Observable.mapMany(Observable, Func1)
public static <K,T,R> Observable<GroupedObservable<K,R>> groupBy(Observable<T> source,
Func1<T,K> keySelector,
Func1<T,R> elementSelector)
K - the key type.T - the source type.R - the resulting observable type.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.
public static <K,T> Observable<GroupedObservable<K,T>> groupBy(Observable<T> source,
Func1<T,K> keySelector)
K - the key type.T - the source type.source - an observable whose elements to group.keySelector - a function to extract the key for each element.
public static <T> Observable<T> mergeDelayError(java.util.List<Observable<T>> source)
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.
source - a list of Observables that emit sequences of items
source list of Observablespublic static <T> Observable<T> mergeDelayError(Observable<Observable<T>> source)
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.
source - an Observable that emits Observables
source Observablepublic static <T> Observable<T> mergeDelayError(Observable<T>... source)
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.
source - a series of Observables that emit sequences of items
source Observablespublic static <T> Observable<T> never()
Observer.
This observable is useful primarily for testing purposes.
T - the type of item (not) emitted by the Observable
Observer
public static <T> Observable<T> onErrorResumeNext(Observable<T> that,
Func1<java.lang.Exception,Observable<T>> resumeFunction)
onError if it encounters an error.
By default, when an Observable encounters an error that prevents it from emitting the expected item to its Observer,
the Observable 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.
that - the source ObservableresumeFunction - a function that returns an Observable that will take over if the source Observable
encounters an error
public static <T> Observable<T> onErrorResumeNext(Observable<T> that,
java.lang.Object resumeFunction)
onError if it encounters an error.
By default, when an Observable encounters an error that prevents it from emitting the expected item to its Observer,
the Observable 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.
that - the source ObservableresumeFunction - a function that returns an Observable that will take over if the source Observable
encounters an error
public static <T> Observable<T> onErrorResumeNext(Observable<T> that,
Observable<T> resumeSequence)
onError if it encounters an error.
By default, when an Observable encounters an error that prevents it from emitting the expected item to its Observer,
the Observable 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.
that - the source ObservableresumeSequence - a function that returns an Observable that will take over if the source Observable
encounters an error
public static <T> Observable<T> onErrorReturn(Observable<T> that,
Func1<java.lang.Exception,T> resumeFunction)
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.
that - the source ObservableresumeFunction - 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
public static <T> ConnectableObservable<T> replay(Observable<T> that)
that - the source Observable
public static <T> Observable<T> cache(Observable<T> that)
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.
public static <T> ConnectableObservable<T> publish(Observable<T> that)
that - the source Observable
public static <T> Observable<T> reduce(Observable<T> sequence,
Func2<T,T,T> accumulator)
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.
T - the type item emitted by the source Observablesequence - the source Observableaccumulator - an accumulator function to be invoked on each element from the sequence, whose
result will be used in the next accumulator call (if applicable)
public static <T> Observable<T> reduce(Observable<T> sequence,
java.lang.Object accumulator)
Observable.reduce(Observable, Func2)
public static <T> Observable<T> aggregate(Observable<T> sequence,
Func2<T,T,T> accumulator)
Observable.reduce(Observable, Func2)
public static <T> Observable<T> aggregate(Observable<T> sequence,
java.lang.Object accumulator)
Observable.reduce(Observable, Func2)
public static <T,R> Observable<R> reduce(Observable<T> sequence,
R initialValue,
Func2<R,T,R> accumulator)
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.
T - the type item emitted by the source ObservableR - the type returned for each item of the target observablesequence - the source ObservableinitialValue - a seed passed into the first execution of the accumulator functionaccumulator - an accumulator function to be invoked on each element from the sequence, whose
result will be used in the next accumulator call (if applicable)
public static <T,R> Observable<R> reduce(Observable<T> sequence,
R initialValue,
java.lang.Object accumulator)
Observable.reduce(Observable, Object, Func2)
public static <T,R> Observable<R> aggregate(Observable<T> sequence,
R initialValue,
Func2<R,T,R> accumulator)
Observable.reduce(Observable, Object, Func2)
public static <T,R> Observable<R> aggregate(Observable<T> sequence,
R initialValue,
java.lang.Object accumulator)
Observable.reduce(Observable, Object, Func2)
public static <T> Observable<T> scan(Observable<T> sequence,
Func2<T,T,T> accumulator)
T - the type item emitted by the source Observablesequence - the source Observableaccumulator - 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)
public static <T> Observable<T> scan(Observable<T> sequence,
java.lang.Object accumulator)
Observable.scan(Observable, Func2)
public static <T,R> Observable<R> scan(Observable<T> sequence,
R initialValue,
Func2<R,T,R> accumulator)
T - the type item emitted by the source ObservableR - the type returned for each item of the target observablesequence - the source ObservableinitialValue - the initial (seed) accumulator valueaccumulator - 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)
public static <T,R> Observable<R> scan(Observable<T> sequence,
R initialValue,
java.lang.Object accumulator)
Observable.scan(Observable, Object, Func2)
public static <T> Observable<java.lang.Boolean> all(Observable<T> sequence,
Func1<T,java.lang.Boolean> predicate)
T - the type of observable.sequence - an observable sequence whose elements to apply the predicate to.predicate - a function to test each element for a condition.
public static <T> Observable<java.lang.Boolean> all(Observable<T> sequence,
java.lang.Object predicate)
T - the type of observable.sequence - an observable sequence whose elements to apply the predicate to.predicate - a function to test each element for a condition.
public static <T> Observable<T> skip(Observable<T> items,
int num)
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.
items - the source Observablenum - the number of items to skip
num itemspublic static <T> Observable<T> switchDo(Observable<Observable<T>> sequenceOfSequences)
Observable sequence of Observable sequences, and transforms it into a single
Observable sequence, which publishes the values of the most recently published Observable sequence.
sequenceOfSequences - the Observable sequence of Observable sequences.
Observable which publishes only the values of the most recently published
Observable sequence.public static <T> Observable<T> synchronize(Observable<T> observable)
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.
T - the type of item emitted by the source Observableobservable - the source Observable
public static <T> Observable<T> take(Observable<T> items,
int num)
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.
items - the source Observablenum - the number of items from the start of the sequence emitted by the source
Observable to emit
num items emitted by the source
Observable
public static <T> Observable<T> takeLast(Observable<T> items,
int count)
count items emitted by the source
Observable.
items - the source Observablecount - the number of items from the end of the sequence emitted by the source
Observable to emit
count items emitted by the source
Observable
public static <T> Observable<T> takeWhile(Observable<T> items,
Func1<T,java.lang.Boolean> predicate)
items - predicate - a function to test each source element for a condition
public static <T> Observable<T> takeWhile(Observable<T> items,
java.lang.Object predicate)
items - predicate - a function to test each source element for a condition
public static <T> Observable<T> takeWhileWithIndex(Observable<T> items,
Func2<T,java.lang.Integer,java.lang.Boolean> predicate)
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.
public static <T> Observable<T> takeWhileWithIndex(Observable<T> items,
java.lang.Object predicate)
public Observable<Timestamped<T>> timestamp()
public static <T> Observable<java.util.List<T>> toList(Observable<T> that)
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.
that - the source Observable
List containing all of the
items emitted by the source Observable
public static <T,R> ConnectableObservable<R> multicast(Observable<T> source,
Subject<T,R> subject)
T - source typeR - result typesource - the source sequence whose elements will be pushed into the specified subject.subject - the subject to push source elements into.
public static <T> Observable<T> toObservable(java.lang.Iterable<T> iterable)
toObservable method.
T - the type of items in the iterable sequence and the type emitted by the resulting
Observableiterable - the source Iterable sequence
public static <T> Observable<T> toObservable(java.util.concurrent.Future<T> future)
Observable.from(Future)
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.
T - the type of of object that the future's returns and the type emitted by the resulting
Observablefuture - the source Future
public static <T> Observable<T> from(java.util.concurrent.Future<T> future)
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.
T - the type of of object that the future's returns and the type emitted by the resulting
Observablefuture - the source Future
public static <T> Observable<T> toObservable(java.util.concurrent.Future<T> future,
long timeout,
java.util.concurrent.TimeUnit unit)
Observable.from(Future, long, TimeUnit)
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.
T - the type of of object that the future's returns and the type emitted by the resulting
Observablefuture - the source Futuretimeout - the maximum time to waitunit - the time unit of the time argument
public static <T> Observable<T> from(java.util.concurrent.Future<T> future,
long timeout,
java.util.concurrent.TimeUnit unit)
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.
T - the type of of object that the future's returns and the type emitted by the resulting
Observablefuture - the source Futuretimeout - the maximum time to waitunit - the time unit of the time argument
public static <T> Observable<T> toObservable(T... items)
Observable.from(Object...)
toObservable method.
T - the type of items in the Array, and the type of items emitted by the resulting
Observableitems - the source Array
public static <T> Observable<java.util.List<T>> toSortedList(Observable<T> sequence)
sequence -
java.lang.ClassCastException - if T objects do not implement Comparable
public static <T> Observable<java.util.List<T>> toSortedList(Observable<T> sequence,
Func2<T,T,java.lang.Integer> sortFunction)
sequence - sortFunction -
public static <T> Observable<java.util.List<T>> toSortedList(Observable<T> sequence,
java.lang.Object sortFunction)
sequence - sortFunction -
public static <R,T0,T1> Observable<R> zip(Observable<T0> w0,
Observable<T1> w1,
Func2<T0,T1,R> reduceFunction)
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.
w0 - one source Observablew1 - another source ObservablereduceFunction - 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
public static <T> Observable<java.lang.Boolean> sequenceEqual(Observable<T> first,
Observable<T> second)
T - type of sequencefirst - observable to comparesecond - observable to compare
public static <T> Observable<java.lang.Boolean> sequenceEqual(Observable<T> first,
Observable<T> second,
Func2<T,T,java.lang.Boolean> equality)
T - type of sequencefirst - observable sequence to comparesecond - observable sequence to compareequality - a function used to compare elements of both sequences
public static <T> Observable<java.lang.Boolean> sequenceEqual(Observable<T> first,
Observable<T> second,
java.lang.Object equality)
T - type of sequencefirst - observable sequence to comparesecond - observable sequence to compareequality - a function used to compare elements of both sequences
public static <R,T0,T1> Observable<R> zip(Observable<T0> w0,
Observable<T1> w1,
java.lang.Object function)
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.
w0 - one source Observablew1 - another source Observablefunction - 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
public static <R,T0,T1,T2> Observable<R> zip(Observable<T0> w0,
Observable<T1> w1,
Observable<T2> w2,
Func3<T0,T1,T2,R> function)
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.
w0 - one source Observablew1 - another source Observablew2 - a third source Observablefunction - 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
public static <R,T0,T1,T2> Observable<R> zip(Observable<T0> w0,
Observable<T1> w1,
Observable<T2> w2,
java.lang.Object function)
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.
w0 - one source Observablew1 - another source Observablew2 - a third source Observablefunction - 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
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)
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.
w0 - one source Observablew1 - another source Observablew2 - a third source Observablew3 - a fourth source ObservablereduceFunction - 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
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)
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.
w0 - one source Observablew1 - another source Observablew2 - a third source Observablew3 - a fourth source Observablefunction - 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
public Observable<T> filter(Func1<T,java.lang.Boolean> predicate)
predicate - a function that evaluates the items emitted by the source Observable, returning
true if they pass the filter
truepublic Observable<T> finallyDo(Action0 action)
onComplete or onError.
action - an action to be called when this observable completes or errors.
public Observable<T> filter(java.lang.Object callback)
callback - a function that evaluates the items emitted by the source Observable, returning
true if they pass the filter
public <R> Observable<R> flatMap(Func1<T,Observable<R>> func)
Note: mapMany and flatMap are equivalent.
func - a function to apply to each item in the sequence, that returns an Observable.
Observable.mapMany(Func1)public <R> Observable<R> flatMap(java.lang.Object callback)
Note: mapMany and flatMap are equivalent.
callback - a function to apply to each item in the sequence that returns an Observable.
Observable.mapMany(Object)public Observable<T> where(Func1<T,java.lang.Boolean> predicate)
predicate - a function that evaluates the items emitted by the source Observable, returning
true if they pass the filter
truepublic <R> Observable<R> map(Func1<T,R> func)
func - a function to apply to each item in the sequence.
public <R> Observable<R> map(java.lang.Object callback)
callback - a function to apply to each item in the sequence.
public <R> Observable<R> mapMany(Func1<T,Observable<R>> func)
Note: mapMany and flatMap are equivalent.
func - a function to apply to each item in the sequence, that returns an Observable.
Observable.flatMap(Func1)public <R> Observable<R> mapMany(java.lang.Object callback)
Note: mapMany and flatMap are equivalent.
callback - a function to apply to each item in the sequence that returns an Observable.
Observable.flatMap(Object)public Observable<Notification<T>> materialize()
public Observable<T> subscribeOn(Scheduler scheduler)
scheduler - the scheduler to perform subscription and unsubscription actions on.
public Observable<T> observeOn(Scheduler scheduler)
scheduler - the scheduler to notify observers on.
public <T2> Observable<T2> dematerialize()
java.lang.Exception - if attempted on Observable not of type Observable<Notification<T>>.public Observable<T> onErrorResumeNext(Func1<java.lang.Exception,Observable<T>> resumeFunction)
onError if it encounters an error.
By default, when an Observable encounters an error that prevents it from emitting the expected
item to its Observer, the Observable 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.
resumeFunction -
public Observable<T> onErrorResumeNext(java.lang.Object resumeFunction)
onError if
it encounters an error.
By default, when an Observable encounters an error that prevents it from emitting the expected
item to its Observer, the Observable 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.
resumeFunction -
public Observable<T> onErrorResumeNext(Observable<T> resumeSequence)
onError if it encounters an error.
By default, when an Observable encounters an error that prevents it from emitting the expected
item to its Observer, the Observable 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.
resumeSequence -
public Observable<T> onErrorReturn(Func1<java.lang.Exception,T> resumeFunction)
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.
resumeFunction -
public Observable<T> onErrorReturn(java.lang.Object resumeFunction)
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.
resumeFunction -
public Observable<T> reduce(Func2<T,T,T> accumulator)
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.
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).
public ConnectableObservable<T> replay()
public Observable<T> cache()
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.
public ConnectableObservable<T> publish()
public Observable<T> reduce(java.lang.Object accumulator)
Observable.reduce(Func2)public Observable<T> aggregate(Func2<T,T,T> accumulator)
Observable.reduce(Func2)public Observable<T> aggregate(java.lang.Object accumulator)
Observable.reduce(Func2)
public <R> Observable<R> reduce(R initialValue,
Func2<R,T,R> accumulator)
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.
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).
public <R> Observable<R> reduce(R initialValue,
java.lang.Object accumulator)
Observable.reduce(Object, Func2)
public <R> Observable<R> aggregate(R initialValue,
Func2<R,T,R> accumulator)
Observable.reduce(Object, Func2)
public <R> Observable<R> aggregate(R initialValue,
java.lang.Object accumulator)
Observable.reduce(Object, Func2)public Observable<T> scan(Func2<T,T,T> accumulator)
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).
public Observable<T> sample(long period,
java.util.concurrent.TimeUnit unit)
period - The period of time that defines the sampling rate.unit - The time unit for the sampling rate time period.
public Observable<T> sample(long period,
java.util.concurrent.TimeUnit unit,
Scheduler scheduler)
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.
public Observable<T> scan(java.lang.Object accumulator)
Observable.scan(Func2)
public <R> Observable<R> scan(R initialValue,
Func2<R,T,R> accumulator)
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).
public <R> Observable<R> scan(R initialValue,
java.lang.Object accumulator)
Observable.scan(Object, Func2)public Observable<java.lang.Boolean> all(Func1<T,java.lang.Boolean> predicate)
predicate - a function to test each element for a condition.
public Observable<java.lang.Boolean> all(java.lang.Object predicate)
predicate - a function to test each element for a condition.
public Observable<T> skip(int num)
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.
num - The number of items to skip
num items from that sequence.public Observable<T> take(int num)
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.
num -
num items from the source
Observable, or all of the items from the source Observable if that Observable emits
fewer than num items.public Observable<T> takeWhile(Func1<T,java.lang.Boolean> predicate)
predicate - a function to test each source element for a condition
public Observable<T> takeWhile(java.lang.Object predicate)
predicate - a function to test each source element for a condition
public Observable<T> takeWhileWithIndex(Func2<T,java.lang.Integer,java.lang.Boolean> predicate)
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.
public Observable<T> takeWhileWithIndex(java.lang.Object predicate)
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.
public Observable<T> takeLast(int count)
count items emitted by the source
Observable.
count - the number of items from the end of the sequence emitted by the source
Observable to emit
count items emitted by the source
Observablepublic <E> Observable<T> takeUntil(Observable<E> other)
E - the other type.other - the observable sequence that terminates propagation of elements of the source sequence.
public Observable<java.util.List<T>> toList()
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.
public Observable<java.util.List<T>> toSortedList()
java.lang.ClassCastException - if T objects do not implement Comparablepublic Observable<java.util.List<T>> toSortedList(Func2<T,T,java.lang.Integer> sortFunction)
sortFunction -
public Observable<java.util.List<T>> toSortedList(java.lang.Object sortFunction)
sortFunction -
public Observable<T> startWith(T... values)
public <K,R> Observable<GroupedObservable<K,R>> groupBy(Func1<T,K> keySelector,
Func1<T,R> elementSelector)
K - the key type.R - the resulting observable type.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.
public <K> Observable<GroupedObservable<K,T>> groupBy(Func1<T,K> keySelector)
K - the key type.keySelector - a function to extract the key for each element.
public BlockingObservable<T> toBlockingObservable()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||