Class ConnectableObservableAsync<T>
- Namespace
- ReactiveUI.Extensions.Async
- Assembly
- ReactiveUI.Extensions.dll
Represents an asynchronous observable sequence that can be connected to a data source, allowing control over when the subscription to the underlying resource is established.
public abstract class ConnectableObservableAsync<T> : ObservableAsync<T>, IObservableAsync<T>
Type Parameters
TThe type of elements produced by the observable sequence.
- Inheritance
-
ConnectableObservableAsync<T>
- Implements
- Inherited Members
- Extension Methods
Remarks
A connectable observable enables explicit control over the connection to the data source, which can be useful for sharing a single subscription among multiple observers or for deferring the start of data emission until explicitly connected. Implementations may vary in how connections are managed and whether multiple connections are supported concurrently.
Constructors
ConnectableObservableAsync()
protected ConnectableObservableAsync()
Methods
ConnectAsync(CancellationToken)
Asynchronously establishes a connection to the target resource and returns a disposable handle for managing the connection's lifetime.
public abstract ValueTask<IAsyncDisposable> ConnectAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the asynchronous connection operation.
Returns
- ValueTask<IAsyncDisposable>
A value task that represents the asynchronous operation. The result contains an IAsyncDisposable that should be disposed to close the connection.
Remarks
The returned IAsyncDisposable must be disposed when the connection is no longer needed to ensure proper resource cleanup. Multiple calls to this method may result in multiple independent connections, depending on the implementation.