subject

Subjects are rx.observer.Observer and rx.observable.Observable at the same time. Whenever you need an explicit object that you can pass on as rx.observable.Observable but need to manualy call the onNext, onError and onCompleted methods of the rx.observable.Observable then you need a Subject.

It is recommended to create an rx.observable.Observable by using rx.observable.Observable.create(), rx.observable.Observable.fromEvent(), rx.observable.Observable.fromFuture(), rx.observable.Observable.generate() and so on.

class rx.subject.Subject
onNext(value)

Calls the onNext method on all observers of this Subject.

onError(exception)

Calls the onError method on all observers of this Subject.

onCompleted()

Calls the onCompleted method on all observers of this Subject.

subscribe(observer)
subscribe(onNext[, onError=None[, onCompleted=none]])

See rx.observable.Observable.subscribe()

dispose()

See rx.observer.Observer.dispose()

static create(observer, observable)

Return a new Subject connecting the observable and the observer.

static synchronize(subject, scheduler=None)

Returns a new Subject that synchonizes the call to the observers onNext methods. If a scheduler is provided, the values are observed on that rx.scheduler.Scheduler.

class rx.subject.AsyncSubject

An AsyncSubject does remember the value from its last onNext call. Subscribers get either this value or wait for the onCompleted call if it has not happend.

If onError gets called, the subject stops waiting for the onCompleted and instead propagates the error to all current and future observers.

If onCompleted gets called, the subject stops waiting for the onCompleted and calls onNext(lastValue) on all current and future observers.

class rx.subject.BehaviorSubject(initialValue)

A BehaviorSubject does remember the value from its most recent onNext call. Subscribers get the current value on subscription and any firther updates via onNext. If no onNext call happend, the observers receive the initial value instead.

If onError gets called, the subject stops propagating value updates and instead propagates the error to all current and future observers.

If onCompleted gets called, the subject stops propagating value updates and instead propagates onCompleted() to all current and future observers.

hasObservers

Returns True if any rx.observer.Observer has subscribed.

Previous topic

scheduler

This Page