Class Subject<T>
Represents an object that is both an observable sequence as well as an observer. Each notification is broadcasted to all subscribed observers.
Inherited Members
Namespace: System.Reactive.Subjects
Assembly: System.Reactive.Linq.dll
Syntax
public sealed class Subject<T> : ISubject<T>, ISubject<T, T>, IObserver<T>, IObservable<T>, IDisposable
Type Parameters
Name | Description |
---|---|
T | The type of the elements processed by the subject. |
Constructors
| Improve this Doc View SourceSubject()
Creates a subject.
Declaration
public Subject()
Properties
| Improve this Doc View SourceHasObservers
Indicates whether the subject has observers subscribed to it.
Declaration
public bool HasObservers { get; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
| Improve this Doc View SourceDispose()
Releases all resources used by the current instance of the Subject<T> class and unsubscribes all observers.
Declaration
public void Dispose()
OnCompleted()
Notifies all subscribed observers about the end of the sequence.
Declaration
public void OnCompleted()
OnError(Exception)
Notifies all subscribed observers about the specified exception.
Declaration
public void OnError(Exception error)
Parameters
Type | Name | Description |
---|---|---|
Exception | error | The exception to send to all currently subscribed observers. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
OnNext(T)
Notifies all subscribed observers about the arrival of the specified element in the sequence.
Declaration
public void OnNext(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to send to all currently subscribed observers. |
Subscribe(IObserver<T>)
Subscribes an observer to the subject.
Declaration
public IDisposable Subscribe(IObserver<T> observer)
Parameters
Type | Name | Description |
---|---|---|
IObserver<T> | observer | Observer to subscribe to the subject. |
Returns
Type | Description |
---|---|
IDisposable | Disposable object that can be used to unsubscribe the observer from the subject. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|