RxJava: Reactive Extensions for the JVM



rx
Interface Observer<T>

Type Parameters:
T - the type of item the Observer expects to observe
All Known Implementing Classes:
AsyncSubject, BehaviorSubject, EmptyObserver, PublishSubject, ReplaySubject, SafeSubscriber, SerializedObserver, SerializedSubscriber, Subject, Subscriber, TestObserver, TestSubject, TestSubscriber

public interface Observer<T>

Provides a mechanism for receiving push-based notifications.

After an Observer calls an Observable's subscribe method, the Observable calls the Observer's Observer.onNext(T) method to provide notifications. A well-behaved Observable will call an Observer's Observer.onCompleted() method exactly once or the Observer's Observer.onError(java.lang.Throwable) method exactly once.

See Also:
RxJava Wiki: Observable

Method Summary
 void onCompleted()
          Notifies the Observer that the Observable has finished sending push-based notifications.
 void onError(java.lang.Throwable e)
          Notifies the Observer that the Observable has experienced an error condition.
 void onNext(T t)
          Provides the Observer with a new item to observe.
 

Method Detail

onCompleted

void onCompleted()
Notifies the Observer that the Observable has finished sending push-based notifications.

The Observable will not call this method if it calls Observer.onError(java.lang.Throwable).


onError

void onError(java.lang.Throwable e)
Notifies the Observer that the Observable has experienced an error condition.

If the Observable calls this method, it will not thereafter call Observer.onNext(T) or Observer.onCompleted().

Parameters:
e - the exception encountered by the Observable

onNext

void onNext(T t)
Provides the Observer with a new item to observe.

The Observable may call this closure 0 or more times.

The Observable will not call this closure again after it calls either Observer.onCompleted() or Observer.onError(java.lang.Throwable).

Parameters:
t - the item emitted by the Observable