>
Defined in Type: SignalAsync
Namespace: ReactiveUI.Primitives.Async
Assembly: ReactiveUI.Primitives.Async.Core.dll
Applies to
net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481, net471
public static IObservableAsync<T> Use<TResource, T>(Func<CancellationToken, ValueTask<TResource>> resourceFactory, Func<TResource, IObservableAsync<T>> signalFactory) where TResource : IAsyncDisposable
Summary: Creates an observable sequence that manages the lifetime of an asynchronous resource, ensuring the resource is disposed when the sequence terminates.
Type parameters
| Name | Description |
|---|---|
TResource | The type of the asynchronous resource that implements IAsyncDisposable. |
T | The type of the elements produced by the observable sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
resourceFactory | Func | A function that asynchronously creates the resource to be used by the observable sequence. The function receives a CancellationToken and returns a ValueTask representing the asynchronous creation of the resource. |
signalFactory | Func | A function that, given the created resource, returns an observable representing the signal sequence that uses the resource. |
Returns: IObservableAsync