Class ObservableAsync<T>
- Namespace
- ReactiveUI.Extensions.Async
- Assembly
- ReactiveUI.Extensions.dll
Represents an asynchronous observable sequence that allows observers to subscribe and receive notifications asynchronously.
public abstract class ObservableAsync<T> : IObservableAsync<T>
Type Parameters
TThe type of the elements produced by the observable sequence.
- Inheritance
-
ObservableAsync<T>
- Implements
- Derived
- Extension Methods
Remarks
Implementations of this class enable the observer pattern for asynchronous event streams, allowing observers to receive notifications as data becomes available. Observers should dispose the returned subscription to stop receiving notifications and release resources. This class is intended to be used as a base for custom asynchronous observable implementations.
Constructors
ObservableAsync()
protected ObservableAsync()
Methods
SubscribeAsync(IObserverAsync<T>, CancellationToken)
Asynchronously subscribes the specified asynchronous observer to receive notifications from the observable sequence.
public ValueTask<IAsyncDisposable> SubscribeAsync(IObserverAsync<T> observer, CancellationToken cancellationToken)
Parameters
observerIObserverAsync<T>The asynchronous observer that will receive notifications. Cannot be null.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the subscription operation.
Returns
- ValueTask<IAsyncDisposable>
A task that represents the asynchronous operation. The result contains an IAsyncDisposable that can be disposed to unsubscribe the observer.
Remarks
The returned IAsyncDisposable should be disposed when the observer no longer wishes to receive notifications. Multiple calls to this method with the same observer will result in multiple independent subscriptions.
SubscribeAsyncCore(IObserverAsync<T>, CancellationToken)
Subscribes the specified asynchronous observer to receive notifications from the observable sequence.
protected abstract ValueTask<IAsyncDisposable> SubscribeAsyncCore(IObserverAsync<T> observer, CancellationToken cancellationToken)
Parameters
observerIObserverAsync<T>The observer that will receive asynchronous notifications. Cannot be null.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the subscription operation.
Returns
- ValueTask<IAsyncDisposable>
A task that represents the asynchronous subscription operation. The result contains an object that can be disposed to unsubscribe the observer.
Remarks
The returned disposable should be disposed when the observer no longer wishes to receive notifications. Multiple calls to this method may result in multiple independent subscriptions.