Subject

class reactivex.subject.Subject

Represents an object that is both an observable sequence as well as an observer. Each notification is broadcasted to all subscribed observers.

__init__()

Creates an observable sequence object from the specified subscription function.

Parameters

subscribe – [Optional] Subscription function

on_next(value)

Notifies all subscribed observers with the value.

Parameters

value (TypeVar(_T)) – The value to send to all subscribed observers.

Return type

None

on_error(error)

Notifies all subscribed observers with the exception.

Parameters

error (Exception) – The exception to send to all subscribed observers.

Return type

None

on_completed()

Notifies all subscribed observers of the end of the sequence.

Return type

None

dispose()

Unsubscribe all observers and release resources.

Return type

None

class reactivex.subject.BehaviorSubject(value)

Represents a value that changes over time. Observers can subscribe to the subject to receive the last (or initial) value and all subsequent notifications.

__init__(value)

Initializes a new instance of the BehaviorSubject class which creates a subject that caches its last value and starts with the specified value.

Parameters

value (TypeVar(_T)) – Initial value sent to observers when no other value has been received by the subject yet.

dispose()

Release all resources.

Releases all resources used by the current instance of the BehaviorSubject class and unsubscribe all observers.

Return type

None

class reactivex.subject.ReplaySubject(buffer_size=None, window=None, scheduler=None)

Represents an object that is both an observable sequence as well as an observer. Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies.

__init__(buffer_size=None, window=None, scheduler=None)

Initializes a new instance of the ReplaySubject class with the specified buffer size, window and scheduler.

Parameters
  • buffer_size (Optional[int]) – [Optional] Maximum element count of the replay buffer.

  • [Optional] (window) – Maximum time length of the replay buffer.

  • scheduler (Optional[SchedulerBase]) – [Optional] Scheduler the observers are invoked on.

dispose()

Releases all resources used by the current instance of the ReplaySubject class and unsubscribe all observers.

Return type

None

class reactivex.subject.AsyncSubject

Represents the result of an asynchronous operation. The last value before the close notification, or the error received through on_error, is sent to all subscribed observers.

__init__()

Creates a subject that can only receive one value and that value is cached for all future observations.

dispose()

Unsubscribe all observers and release resources.

Return type

None