Top Description Fields Constructors Methods
rx.observers

public final Class Observers

extends Object
Class Inheritance
Imports
rx.Observer, rx.exceptions.OnErrorNotImplementedException, rx.functions.*

Helper methods and utilities for creating and working with Observer objects.

Field Summary

Modifier and TypeField and Description
private static final Observer<Object>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <
the observed value type
T
>
Observer<T>

Returns:

an Observer that calls onNext for each emitted item from the Observable the Observer subscribes to
create
(final Action1<? super T>
a function that handles each item emitted by an Observable
onNext
)

Creates an Observer that receives the emissions of any Observable it subscribes to via onNext but ignores onCompleted notifications; it will throw an OnErrorNotImplementedException if onError is invoked.

public static <
the observed value type
T
>
Observer<T>

Returns:

an Observer that calls onNext for each emitted item from the Observable the Observer subscribes to, and calls onError if the Observable notifies of an error
create
(final Action1<? super T>
a function that handles each item emitted by an Observable
onNext
,
final Action1<Throwable>
a function that handles an error notification if one is sent by an Observable
onError
)

Creates an Observer that receives the emissions of any Observable it subscribes to via onNext and handles any onError notification but ignores an onCompleted notification.

public static <
the observed value type
T
>
Observer<T>

Returns:

an Observer that calls onNext for each emitted item from the Observable the Observer subscribes to, calls onError if the Observable notifies of an error, and calls onComplete if the Observable notifies that the observable sequence is complete
create
(final Action1<? super T>
a function that handles each item emitted by an Observable
onNext
,
final Action1<Throwable>
a function that handles an error notification if one is sent by an Observable
onError
,
final Action0
a function that handles a sequence complete notification if one is sent by an Observable
onComplete
)

Creates an Observer that receives the emissions of any Observable it subscribes to via onNext and handles any onError or onCompleted notifications.

public static <
the observed value type
T
>
Observer<T>

Returns:

an inert Observer
empty
()

Returns an inert Observer that does nothing in response to the emissions or notifications from any Observable it subscribes to but will throw an exception if its onError method is called.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EMPTYback to summary
private static final Observer<Object> EMPTY

Constructor Detail

Observersback to summary
private Observers()

Method Detail

createback to summary
public static <T> Observer<T> create(final Action1<? super T> onNext)

Creates an Observer that receives the emissions of any Observable it subscribes to via onNext but ignores onCompleted notifications; it will throw an OnErrorNotImplementedException if onError is invoked.

Parameters
<T>
the observed value type
onNext:Action1<? super T>

a function that handles each item emitted by an Observable

Returns:Observer<T>

an Observer that calls onNext for each emitted item from the Observable the Observer subscribes to

Exceptions
IllegalArgumentException:
if onNext is null
createback to summary
public static <T> Observer<T> create(final Action1<? super T> onNext, final Action1<Throwable> onError)

Creates an Observer that receives the emissions of any Observable it subscribes to via onNext and handles any onError notification but ignores an onCompleted notification.

Parameters
<T>
the observed value type
onNext:Action1<? super T>

a function that handles each item emitted by an Observable

onError:Action1<Throwable>

a function that handles an error notification if one is sent by an Observable

Returns:Observer<T>

an Observer that calls onNext for each emitted item from the Observable the Observer subscribes to, and calls onError if the Observable notifies of an error

Exceptions
IllegalArgumentException:
if either onNext or onError are null
createback to summary
public static <T> Observer<T> create(final Action1<? super T> onNext, final Action1<Throwable> onError, final Action0 onComplete)

Creates an Observer that receives the emissions of any Observable it subscribes to via onNext and handles any onError or onCompleted notifications.

Parameters
<T>
the observed value type
onNext:Action1<? super T>

a function that handles each item emitted by an Observable

onError:Action1<Throwable>

a function that handles an error notification if one is sent by an Observable

onComplete:Action0

a function that handles a sequence complete notification if one is sent by an Observable

Returns:Observer<T>

an Observer that calls onNext for each emitted item from the Observable the Observer subscribes to, calls onError if the Observable notifies of an error, and calls onComplete if the Observable notifies that the observable sequence is complete

Exceptions
IllegalArgumentException:
if either onNext, onError, or onComplete are null
emptyback to summary
public static <T> Observer<T> empty()

Returns an inert Observer that does nothing in response to the emissions or notifications from any Observable it subscribes to but will throw an exception if its onError method is called.

Parameters
<T>
the observed value type
Returns:Observer<T>

an inert Observer

Annotations
@SuppressWarnings:unchecked