Interface IObservableAsync<T>
- Namespace
- ReactiveUI.Extensions.Async
- Assembly
- ReactiveUI.Extensions.dll
Represents a provider for asynchronous push-based notifications that supports asynchronous subscription and disposal.
public interface IObservableAsync<T>
Type Parameters
TThe type of elements produced by the observable sequence.
- Extension Methods
Remarks
Use this interface to implement observable sequences that allow observers to subscribe asynchronously and receive notifications in an asynchronous manner. This is useful for scenarios where subscription or unsubscription may involve asynchronous operations, such as network or I/O-bound tasks. Implementations should ensure that notifications are delivered according to the observer's contract and that resources are released when the subscription is disposed.
Methods
SubscribeAsync(IObserverAsync<T>, CancellationToken)
Subscribes the specified asynchronous observer to receive notifications from the observable sequence.
ValueTask<IAsyncDisposable> SubscribeAsync(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 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 observers may be subscribed concurrently.