Skip to content

,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)

View source

Summary: Subscribes to the asynchronous data source and invokes the specified callbacks for each item, error, or completion notification.

Type parameters

NameDescription
TThe type of elements in the sequence.

Parameters

NameTypeDescription
source[IObservableAsync](#The source observable sequence.
onNextAsyncFuncA delegate that is invoked asynchronously for each item received from the data source. The delegate receives the item and a cancellation token.
onErrorResumeAsyncFunc?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.
onCompletedAsyncFunc?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.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the subscription and any in-progress callbacks.

Returns: ValueTask -- A value task that represents the asynchronous operation. The result is an IAsyncDisposable that can be disposed to unsubscribe from the data source.

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

TypeCondition
System.ArgumentNullExceptionThrown 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)

View source

Summary: Subscribes to the asynchronous data source and invokes the specified callbacks for each item or error notification.

Type parameters

NameDescription
TThe type of elements in the sequence.

Parameters

NameTypeDescription
source[IObservableAsync](#The source observable sequence.
onNextAsyncFuncA delegate that is invoked asynchronously for each item received from the data source.
onErrorResumeAsyncFunc?An optional delegate that is invoked asynchronously if an error occurs during data processing.

Returns: ValueTask -- A value task that represents the asynchronous operation. The result is an IAsyncDisposable that can be disposed to unsubscribe from the data source.

Exceptions

TypeCondition
System.ArgumentNullExceptionThrown 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)

View source

Summary: Subscribes to the asynchronous data source and invokes the specified callbacks for each item, error, or completion notification.

Type parameters

NameDescription
TThe type of elements in the sequence.

Parameters

NameTypeDescription
source[IObservableAsync](#The source observable sequence.
onNextAsyncFuncA delegate that is invoked asynchronously for each item received from the data source.
onErrorResumeAsyncFunc?An optional delegate that is invoked asynchronously if an error occurs during data processing.
onCompletedAsyncFunc?An optional delegate that is invoked asynchronously when the data source completes successfully.

Returns: ValueTask -- A value task that represents the asynchronous operation. The result is an IAsyncDisposable that can be disposed to unsubscribe from the data source.

Exceptions

TypeCondition
System.ArgumentNullExceptionThrown if the underlying data source is null.

4. Overload

public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Action<T> onNext, CancellationToken cancellationToken)

View source

Summary: Subscribes to the observable sequence and invokes the specified action for each element received.

Type parameters

NameDescription
TThe type of elements in the sequence.

Parameters

NameTypeDescription
source[IObservableAsync](#The source observable sequence.
onNextActionAn action to invoke for each element in the sequence. Cannot be null.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the subscription operation.

Returns: ValueTask -- A value task that represents the asynchronous subscription operation. The result contains an IAsyncDisposable that can be disposed to unsubscribe from the sequence.

Exceptions

TypeCondition
System.ArgumentNullExceptionThrown if onNext is null.

5. Overload

public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Action<T> onNext)

View source

Summary: Subscribes to the observable sequence and invokes the specified action for each element received.

Type parameters

NameDescription
TThe type of elements in the sequence.

Parameters

NameTypeDescription
source[IObservableAsync](#The source observable sequence.
onNextActionAn action to invoke for each element in the sequence. Cannot be null.

Returns: ValueTask -- A value task that represents the asynchronous subscription operation. The result contains an IAsyncDisposable that can be disposed to unsubscribe from the sequence.

Exceptions

TypeCondition
System.ArgumentNullExceptionThrown 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)

View source

Summary: Subscribes to the observable sequence asynchronously, invoking the specified callbacks for each element, error, or completion notification.

Type parameters

NameDescription
TThe type of elements in the sequence.

Parameters

NameTypeDescription
source[IObservableAsync](#The source observable sequence.
onNextActionAn action to invoke for each element in the sequence. Cannot be null.
onErrorResumeAction?An optional action to invoke if an error occurs during the sequence. If null, errors are not handled by the subscriber.
onCompletedAction?An optional action to invoke when the sequence completes. If null, completion is not handled by the subscriber.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the subscription.

Returns: ValueTask -- A value task that represents the asynchronous subscription operation. The result is an IAsyncDisposable that can be disposed to unsubscribe from the sequence.

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

TypeCondition
System.ArgumentNullExceptionThrown if onNext is null, or if the underlying source is null.

7. Overload

public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source)

View source

Summary: Subscribes to the source without handling any items asynchronously.

Type parameters

NameDescription
TThe type of elements in the sequence.

Parameters

NameTypeDescription
source[IObservableAsync](#The source observable sequence.

Returns: ValueTask -- A value task that represents the asynchronous subscription operation. The result is an IAsyncDisposable that can be disposed to unsubscribe.

8. Overload

public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Func<T, CancellationToken, ValueTask> onNextAsync)

View source

Summary: Subscribes asynchronously to receive notifications for each item published by the source.

Type parameters

NameDescription
TThe type of elements in the sequence.

Parameters

NameTypeDescription
source[IObservableAsync](#The source observable sequence.
onNextAsyncFuncA 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 -- A ValueTask that represents the asynchronous subscription operation. The result contains an IAsyncDisposable that can be disposed to unsubscribe from the source.

9. Overload

public static ValueTask<IAsyncDisposable> SubscribeAsync<T>(this IObservableAsync<T> source, Func<T, CancellationToken, ValueTask> onNextAsync, CancellationToken cancellationToken)

View source

Summary: Subscribes asynchronously to receive notifications for each item in the sequence using the specified asynchronous callback.

Type parameters

NameDescription
TThe type of elements in the sequence.

Parameters

NameTypeDescription
source[IObservableAsync](#The source observable sequence.
onNextAsyncFuncA 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.
cancellationTokenCancellationTokenA token that can be used to cancel the subscription operation.

Returns: ValueTask -- A ValueTask that represents the asynchronous subscription operation. The result is an IAsyncDisposable that can be disposed to unsubscribe from the sequence.

Exceptions

TypeCondition
System.ArgumentNullExceptionThrown if the underlying source is null.