,System.Func{--0,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask},System.Func{System.Exception,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask},System.Func{ReactiveUI.Extensions.Async.Result,System.Threading.Tasks.ValueTask},System.Threading.CancellationToken)} ,System.Func{--0,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask},System.Func{System.Exception,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask})} ,System.Func{--0,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask},System.Func{System.Exception,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask},System.Func{ReactiveUI.Extensions.Async.Result,System.Threading.Tasks.ValueTask})} ,System.Action{--0},System.Threading.CancellationToken)} ,System.Action{--0})} ,System.Action{--0},System.Action{System.Exception},System.Action{ReactiveUI.Extensions.Async.Result},System.Threading.CancellationToken)} )} ,System.Func{--0,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask})} ,System.Func{--0,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask},System.Threading.CancellationToken)}
ObservableAsync.SubscribeAsync(IObservableAsync, Func, Func?, Func?, CancellationToken) method¶
Defined in
Type: ObservableAsync
Namespace: ReactiveUI.Extensions.Async
Assembly: ReactiveUI.Extensions.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
Overloads¶
- 1.
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Func<T, CancellationToken, ValueTask> onNextAsync, Func<Exception, CancellationToken, ValueTask>? onErrorResumeAsync, Func<Result, ValueTask>? onCompletedAsync, CancellationToken cancellationToken) - 2.
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Func<T, CancellationToken, ValueTask> onNextAsync, Func<Exception, CancellationToken, ValueTask>? onErrorResumeAsync) - 3.
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Func<T, CancellationToken, ValueTask> onNextAsync, Func<Exception, CancellationToken, ValueTask>? onErrorResumeAsync, Func<Result, ValueTask>? onCompletedAsync) - 4.
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Action<T> onNext, CancellationToken cancellationToken) - 5.
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Action<T> onNext) - 6.
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Action<T> onNext, Action<Exception>? onErrorResume, Action<Result>? onCompleted, CancellationToken cancellationToken) - 7.
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source) - 8.
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Func<T, CancellationToken, ValueTask> onNextAsync) - 9.
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Func<T, CancellationToken, ValueTask> onNextAsync, CancellationToken cancellationToken)
1. Overload¶
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Func<T, CancellationToken, ValueTask> onNextAsync, Func<Exception, CancellationToken, ValueTask>? onErrorResumeAsync, Func<Result, ValueTask>? onCompletedAsync, CancellationToken cancellationToken)
Summary: Subscribes to the asynchronous data source and invokes the specified callbacks for each item, error, or completion notification.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | [IObservableAsync | The source observable sequence. |
onNextAsync | Func | A delegate that is invoked asynchronously for each item received from the data source. The delegate receives the item and a cancellation token. |
onErrorResumeAsync | Func | An optional delegate that is invoked asynchronously if an error occurs during data processing. The delegate receives the exception and a cancellation token. If null, errors are not handled by the subscriber. |
onCompletedAsync | Func | An optional delegate that is invoked asynchronously when the data source completes successfully. The delegate receives a result indicating the completion status. If null, no action is taken on completion. |
cancellationToken | CancellationToken | A cancellation token that can be used to cancel the subscription and any in-progress callbacks. |
Returns: ValueTask
Remarks
The returned IAsyncDisposable should be disposed when the subscription is no longer needed to release resources and stop receiving notifications. Callbacks may be invoked concurrently; implement thread safety in the provided delegates if required.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if the underlying data source is null. |
2. Overload¶
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Func<T, CancellationToken, ValueTask> onNextAsync, Func<Exception, CancellationToken, ValueTask>? onErrorResumeAsync)
Summary: Subscribes to the asynchronous data source and invokes the specified callbacks for each item or error notification.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | [IObservableAsync | The source observable sequence. |
onNextAsync | Func | A delegate that is invoked asynchronously for each item received from the data source. |
onErrorResumeAsync | Func | An optional delegate that is invoked asynchronously if an error occurs during data processing. |
Returns: ValueTask
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if the underlying data source is null. |
3. Overload¶
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Func<T, CancellationToken, ValueTask> onNextAsync, Func<Exception, CancellationToken, ValueTask>? onErrorResumeAsync, Func<Result, ValueTask>? onCompletedAsync)
Summary: Subscribes to the asynchronous data source and invokes the specified callbacks for each item, error, or completion notification.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | [IObservableAsync | The source observable sequence. |
onNextAsync | Func | A delegate that is invoked asynchronously for each item received from the data source. |
onErrorResumeAsync | Func | An optional delegate that is invoked asynchronously if an error occurs during data processing. |
onCompletedAsync | Func | An optional delegate that is invoked asynchronously when the data source completes successfully. |
Returns: ValueTask
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if the underlying data source is null. |
4. Overload¶
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Action<T> onNext, CancellationToken cancellationToken)
Summary: Subscribes to the observable sequence and invokes the specified action for each element received.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | [IObservableAsync | The source observable sequence. |
onNext | Action | An action to invoke for each element in the sequence. Cannot be null. |
cancellationToken | CancellationToken | A cancellation token that can be used to cancel the subscription operation. |
Returns: ValueTask
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if onNext is null. |
5. Overload¶
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Action<T> onNext)
Summary: Subscribes to the observable sequence and invokes the specified action for each element received.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | [IObservableAsync | The source observable sequence. |
onNext | Action | An action to invoke for each element in the sequence. Cannot be null. |
Returns: ValueTask
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if onNext is null. |
6. Overload¶
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Action<T> onNext, Action<Exception>? onErrorResume, Action<Result>? onCompleted, CancellationToken cancellationToken)
Summary: Subscribes to the observable sequence asynchronously, invoking the specified callbacks for each element, error, or completion notification.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | [IObservableAsync | The source observable sequence. |
onNext | Action | An action to invoke for each element in the sequence. Cannot be null. |
onErrorResume | Action | An optional action to invoke if an error occurs during the sequence. If null, errors are not handled by the subscriber. |
onCompleted | Action | An optional action to invoke when the sequence completes. If null, completion is not handled by the subscriber. |
cancellationToken | CancellationToken | A cancellation token that can be used to cancel the subscription. |
Returns: ValueTask
Remarks
The returned IAsyncDisposable should be disposed when the subscription is no longer needed to release resources and stop receiving notifications. This method enables asynchronous, push-based event handling for observable sequences.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if onNext is null, or if the underlying source is null. |
7. Overload¶
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source)
Summary: Subscribes to the source without handling any items asynchronously.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | [IObservableAsync | The source observable sequence. |
Returns: ValueTask
8. Overload¶
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Func<T, CancellationToken, ValueTask> onNextAsync)
Summary: Subscribes asynchronously to receive notifications for each item published by the source.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | [IObservableAsync | The source observable sequence. |
onNextAsync | Func | A delegate that is invoked asynchronously for each item published. The delegate receives the item and a cancellation token, and returns a ValueTask that completes when processing is finished. Cannot be null. |
Returns: ValueTask
9. Overload¶
public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Func<T, CancellationToken, ValueTask> onNextAsync, CancellationToken cancellationToken)
Summary: Subscribes asynchronously to receive notifications for each item in the sequence using the specified asynchronous callback.
Type parameters
| Name | Description |
|---|---|
T | The type of elements in the sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | [IObservableAsync | The source observable sequence. |
onNextAsync | Func | A function to invoke asynchronously for each item in the sequence. The function receives the item and a cancellation token, and returns a ValueTask that completes when processing is finished. |
cancellationToken | CancellationToken | A token that can be used to cancel the subscription operation. |
Returns: ValueTask
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if the underlying source is null. |