Class AsyncSubject<T>
Represents the result of an asynchronous operation. The last value before the OnCompleted notification, or the error received through OnError, is sent to all subscribed observers.
Inherited Members
Namespace: System.Reactive.Subjects
Assembly: System.Reactive.Linq.dll
Syntax
public sealed class AsyncSubject<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 SourceAsyncSubject()
Creates a subject that can only receive one value and that value is cached for all future observations.
Declaration
public AsyncSubject()
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 |
IsCompleted
Gets whether the AsyncSubject has completed.
Declaration
public bool IsCompleted { get; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
| Improve this Doc View SourceDispose()
Unsubscribe all observers and release resources.
Declaration
public void Dispose()
GetResult()
Gets the last element of the subject, potentially blocking until the subject completes successfully or exceptionally.
Declaration
public T GetResult()
Returns
Type | Description |
---|---|
T | The last element of the subject. Throws an InvalidOperationException if no element was received. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | The source sequence is empty. |
OnCompleted()
Notifies all subscribed observers about the end of the sequence, also causing the last received value to be sent out (if any).
Declaration
public void OnCompleted()
OnError(Exception)
Notifies all subscribed observers about the exception.
Declaration
public void OnError(Exception error)
Parameters
Type | Name | Description |
---|---|---|
Exception | error | The exception to send to all observers. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
OnNext(T)
Sends a value to the subject. The last value received before successful termination will be sent to all subscribed and future observers.
Declaration
public void OnNext(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to store in the subject. |
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 |
|