Package rx.observers
Class Observers
- java.lang.Object
-
- rx.observers.Observers
-
public final class Observers extends java.lang.Object
Helper methods and utilities for creating and working withObserver
objects.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
Observers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Observer<T>
create(Action1<? super T> onNext)
Creates anObserver
that receives the emissions of anyObservable
it subscribes to viaonNext
but ignoresonCompleted
notifications; it will throw anOnErrorNotImplementedException
ifonError
is invoked.static <T> Observer<T>
create(Action1<? super T> onNext, Action1<java.lang.Throwable> onError)
Creates anObserver
that receives the emissions of anyObservable
it subscribes to viaonNext
and handles anyonError
notification but ignores anonCompleted
notification.static <T> Observer<T>
create(Action1<? super T> onNext, Action1<java.lang.Throwable> onError, Action0 onComplete)
Creates anObserver
that receives the emissions of anyObservable
it subscribes to viaonNext
and handles anyonError
oronCompleted
notifications.static <T> Observer<T>
empty()
-
-
-
Field Detail
-
EMPTY
private static final Observer<java.lang.Object> EMPTY
-
-
Method Detail
-
empty
public static <T> Observer<T> empty()
Returns an inertObserver
that does nothing in response to the emissions or notifications from anyObservable
it subscribes to but will throw an exception if itsonError
method is called.- Type Parameters:
T
- the observed value type- Returns:
- an inert
Observer
-
create
public static <T> Observer<T> create(Action1<? super T> onNext)
Creates anObserver
that receives the emissions of anyObservable
it subscribes to viaonNext
but ignoresonCompleted
notifications; it will throw anOnErrorNotImplementedException
ifonError
is invoked.- Type Parameters:
T
- the observed value type- Parameters:
onNext
- a function that handles each item emitted by anObservable
- Returns:
- an
Observer
that callsonNext
for each emitted item from theObservable
theObserver
subscribes to - Throws:
java.lang.IllegalArgumentException
- ifonNext
isnull
-
create
public static <T> Observer<T> create(Action1<? super T> onNext, Action1<java.lang.Throwable> onError)
Creates anObserver
that receives the emissions of anyObservable
it subscribes to viaonNext
and handles anyonError
notification but ignores anonCompleted
notification.- Type Parameters:
T
- the observed value type- Parameters:
onNext
- a function that handles each item emitted by anObservable
onError
- a function that handles an error notification if one is sent by anObservable
- Returns:
- an
Observer
that callsonNext
for each emitted item from theObservable
theObserver
subscribes to, and callsonError
if theObservable
notifies of an error - Throws:
java.lang.IllegalArgumentException
- if eitheronNext
oronError
arenull
-
create
public static <T> Observer<T> create(Action1<? super T> onNext, Action1<java.lang.Throwable> onError, Action0 onComplete)
Creates anObserver
that receives the emissions of anyObservable
it subscribes to viaonNext
and handles anyonError
oronCompleted
notifications.- Type Parameters:
T
- the observed value type- Parameters:
onNext
- a function that handles each item emitted by anObservable
onError
- a function that handles an error notification if one is sent by anObservable
onComplete
- a function that handles a sequence complete notification if one is sent by anObservable
- Returns:
- an
Observer
that callsonNext
for each emitted item from theObservable
theObserver
subscribes to, callsonError
if theObservable
notifies of an error, and callsonComplete
if theObservable
notifies that the observable sequence is complete - Throws:
java.lang.IllegalArgumentException
- if eitheronNext
,onError
, oronComplete
arenull
-
-