observer

Observers are the main receivers of notification in rx. Every Observer has an onNext(), an onError() and an onCompleted() method. An Observer is also a rx.disposable.Disposable.

class rx.observer.Observer

Represents the IObserver Interface. Has some static helper methods attached

static create(onNext=None, onError=None, onCompleted=None)

Creates and returns an Observer. The default for onNext() is to ignore the value, the default for onError() is to raise the error, the default for onCompleted() is to ignore the notification.

static synchronize(observer, lock=None)

Returns a synchronized Observer that aquires the lock before either onNext(), onError() or onCompleted() get called. If no lock is provided, a new RLock is used as default.

static fromNotifier(handler)

Returns an Observer, that wraps the handler. The handler gets called with rx.notification.Notification instances representing the events that happend.

toNotifier()

Returns a function that accepts rx.notification.Notification objects and calls their accept() method with self as the parameter.

asObserver()

Returns an Observer to hide the type of the original Observer.

checked()

Returns an Observer that checks if onError() or onCompleted() have already been called and if so, raises an Exception.

onNext(value)

The method that gets called whenever a value was produced by the rx.observable.Observable.

onError(exception)

The method that gets called when an error occured in the rx.observable.Observable. After an error an rx.observable.Observable is regarded as closed and does not produce any further calls to onNext(), onError(), or onCompleted().

onCompleted(value)

The method that gets called when the rx.observable.Observable finished. After completion an rx.observable.Observable is regarded as closed and does not produce any further calls to onNext(), onError(), or onCompleted().

dispose()

Disposes this observer to not receive any further onNext, onError or onCompleted calls.

Previous topic

observable

Next topic

scheduler

This Page