Package rx.observers
Class Observers
- java.lang.Object
-
- rx.observers.Observers
-
public final class Observers extends java.lang.ObjectHelper methods and utilities for creating and working withObserverobjects.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateObservers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Observer<T>create(Action1<? super T> onNext)Creates anObserverthat receives the emissions of anyObservableit subscribes to viaonNextbut ignoresonCompletednotifications; it will throw anOnErrorNotImplementedExceptionifonErroris invoked.static <T> Observer<T>create(Action1<? super T> onNext, Action1<java.lang.Throwable> onError)Creates anObserverthat receives the emissions of anyObservableit subscribes to viaonNextand handles anyonErrornotification but ignores anonCompletednotification.static <T> Observer<T>create(Action1<? super T> onNext, Action1<java.lang.Throwable> onError, Action0 onComplete)Creates anObserverthat receives the emissions of anyObservableit subscribes to viaonNextand handles anyonErrororonCompletednotifications.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 inertObserverthat does nothing in response to the emissions or notifications from anyObservableit subscribes to but will throw an exception if itsonErrormethod 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 anObserverthat receives the emissions of anyObservableit subscribes to viaonNextbut ignoresonCompletednotifications; it will throw anOnErrorNotImplementedExceptionifonErroris invoked.- Type Parameters:
T- the observed value type- Parameters:
onNext- a function that handles each item emitted by anObservable- Returns:
- an
Observerthat callsonNextfor each emitted item from theObservabletheObserversubscribes to - Throws:
java.lang.IllegalArgumentException- ifonNextisnull
-
create
public static <T> Observer<T> create(Action1<? super T> onNext, Action1<java.lang.Throwable> onError)
Creates anObserverthat receives the emissions of anyObservableit subscribes to viaonNextand handles anyonErrornotification but ignores anonCompletednotification.- Type Parameters:
T- the observed value type- Parameters:
onNext- a function that handles each item emitted by anObservableonError- a function that handles an error notification if one is sent by anObservable- Returns:
- an
Observerthat callsonNextfor each emitted item from theObservabletheObserversubscribes to, and callsonErrorif theObservablenotifies of an error - Throws:
java.lang.IllegalArgumentException- if eitheronNextoronErrorarenull
-
create
public static <T> Observer<T> create(Action1<? super T> onNext, Action1<java.lang.Throwable> onError, Action0 onComplete)
Creates anObserverthat receives the emissions of anyObservableit subscribes to viaonNextand handles anyonErrororonCompletednotifications.- Type Parameters:
T- the observed value type- Parameters:
onNext- a function that handles each item emitted by anObservableonError- a function that handles an error notification if one is sent by anObservableonComplete- a function that handles a sequence complete notification if one is sent by anObservable- Returns:
- an
Observerthat callsonNextfor each emitted item from theObservabletheObserversubscribes to, callsonErrorif theObservablenotifies of an error, and callsonCompleteif theObservablenotifies that the observable sequence is complete - Throws:
java.lang.IllegalArgumentException- if eitheronNext,onError, oronCompletearenull
-
-