|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectrx.observables.BlockingObservable<T>
T - public class BlockingObservable<T>
An extension of Observable that provides blocking operators.
You construct a BlockingObservable from an Observable with BlockingObservable.from(Observable) or Observable.toBlockingObservable()
The documentation for this interface makes use of a form of marble diagram that has been modified to illustrate blocking operators. The following legend explains these marble diagrams:
For more information see the Blocking Observable Operators page at the RxJava Wiki.
| Method Summary | ||
|---|---|---|
void |
forEach(Action1<? super T> onNext)
Invoke a method on each item emitted by the Observable; block until the Observable
completes. |
|
static
|
from(Observable<? extends T> o)
Convert an Observable into a BlockingObservable. |
|
java.util.Iterator<T> |
getIterator()
Returns an Iterator that iterates over all items emitted by a specified Observable. |
|
T |
last()
Returns the last item emitted by a specified Observable. |
|
T |
last(Func1<? super T,java.lang.Boolean> predicate)
Returns the last item emitted by a specified Observable that matches a predicate. |
|
T |
lastOrDefault(T defaultValue)
Returns the last item emitted by a specified Observable, or a default value if no
items are emitted. |
|
T |
lastOrDefault(T defaultValue,
Func1<? super T,java.lang.Boolean> predicate)
Returns the last item emitted by a specified Observable that matches a predicate, or
a default value if no such items are emitted. |
|
java.lang.Iterable<T> |
mostRecent(T initialValue)
Returns an Iterable that always returns the item most recently emitted by an Observable. |
|
java.lang.Iterable<T> |
next()
Returns an Iterable that blocks until the Observable emits another item,
then returns that item. |
|
T |
single()
If the Observable completes after emitting a single item, return that item,
otherwise throw an exception. |
|
T |
single(Func1<? super T,java.lang.Boolean> predicate)
If the Observable completes after emitting a single item that matches a given
predicate, return that item, otherwise throw an exception. |
|
T |
singleOrDefault(T defaultValue)
If the Observable completes after emitting a single item, return that item; if it
emits more than one item, throw an exception; if it emits no items, return a default value. |
|
T |
singleOrDefault(T defaultValue,
Func1<? super T,java.lang.Boolean> predicate)
If the Observable completes after emitting a single item that matches a predicate,
return that item; if it emits more than one such item, throw an exception; if it emits no
items, return a default value. |
|
java.util.concurrent.Future<T> |
toFuture()
Returns a Future representing the single value emitted by an Observable. |
|
java.lang.Iterable<T> |
toIterable()
Converts an Observable into an Iterable. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <T> BlockingObservable<T> from(Observable<? extends T> o)
public void forEach(Action1<? super T> onNext)
Observable; block until the Observable
completes.
NOTE: This will block even if the Observable is asynchronous.
This is similar to Observable.subscribe(Observer), but it blocks. Because it blocks it does
not need the Observer.onCompleted() or Observer.onError(Throwable) methods.
onNext - the Action1 to invoke for every item emitted by the Observable
java.lang.RuntimeException - if an error occurspublic java.util.Iterator<T> getIterator()
Iterator that iterates over all items emitted by a specified Observable.
Iterator that can iterate over the items emitted by the Observablepublic T last()
Observable.
Observable
java.lang.IllegalArgumentException - if source contains no elementspublic T last(Func1<? super T,java.lang.Boolean> predicate)
Observable that matches a predicate.
predicate - a predicate function to evaluate items emitted by the Observable
Observable that matches the predicatepublic T lastOrDefault(T defaultValue)
Observable, or a default value if no
items are emitted.
defaultValue - a default value to return if the Observable emits no items
Observable, or the default value if no items
are emitted
public T lastOrDefault(T defaultValue,
Func1<? super T,java.lang.Boolean> predicate)
Observable that matches a predicate, or
a default value if no such items are emitted.
defaultValue - a default value to return if the Observable emits no matching itemspredicate - a predicate function to evaluate items emitted by the Observable
Observable that matches the predicate, or the
default value if no matching items are emittedpublic java.lang.Iterable<T> mostRecent(T initialValue)
Iterable that always returns the item most recently emitted by an Observable.
initialValue - the initial value that will be yielded by the Iterable sequence if the Observable has not yet emitted an item
Iterable that on each iteration returns the item that the Observable has most recently emittedpublic java.lang.Iterable<T> next()
Iterable that blocks until the Observable emits another item,
then returns that item.
Iterable that blocks upon each iteration until the Observable emits a new item, whereupon the Iterable returns that itempublic T single()
Observable completes after emitting a single item, return that item,
otherwise throw an exception.
Observablepublic T single(Func1<? super T,java.lang.Boolean> predicate)
Observable completes after emitting a single item that matches a given
predicate, return that item, otherwise throw an exception.
predicate - a predicate function to evaluate items emitted by the Observable
Observable that matches the predicatepublic T singleOrDefault(T defaultValue)
Observable completes after emitting a single item, return that item; if it
emits more than one item, throw an exception; if it emits no items, return a default value.
defaultValue - a default value to return if the Observable emits no items
Observable, or the default value if no items
are emitted
public T singleOrDefault(T defaultValue,
Func1<? super T,java.lang.Boolean> predicate)
Observable completes after emitting a single item that matches a predicate,
return that item; if it emits more than one such item, throw an exception; if it emits no
items, return a default value.
defaultValue - a default value to return if the Observable emits no matching itemspredicate - a predicate function to evaluate items emitted by the Observable
Observable that matches the predicate, or the
default value if no such items are emittedpublic java.util.concurrent.Future<T> toFuture()
Future representing the single value emitted by an Observable.
toFuture() throws an exception if the Observable emits more than one item. If
the Observable may emit more than item, use toList().toFuture().
Future that expects a single item to be emitted by the source Observablepublic java.lang.Iterable<T> toIterable()
Observable into an Iterable.
Iterable version of the underlying Observable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||