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.Func{--0,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask})} ,System.Action{--0},System.Action{System.Exception},System.Action{ReactiveUI.Extensions.Async.Result})} )}

ObservableAsync.Do(IObservableAsync, Func?, Func?, Func?) 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 IObservableAsync<T> Do<T>(this IObservableAsync<T> @this, Func<T, CancellationToken, ValueTask>? onNext, Func<Exception, CancellationToken, ValueTask>? onErrorResume, Func<Result, ValueTask>? onCompleted)
  • 2. public static IObservableAsync<T> Do<T>(this IObservableAsync<T> @this, Func<T, CancellationToken, ValueTask>? onNext)
  • 3. public static IObservableAsync<T> Do<T>(this IObservableAsync<T> @this, Action<T>? onNext, Action<Exception>? onErrorResume, Action<Result>? onCompleted)
  • 4. public static IObservableAsync<T> Do<T>(this IObservableAsync<T> @this)

1. Overload

public static IObservableAsync<T> Do<T>(this IObservableAsync<T> @this, Func<T, CancellationToken, ValueTask>? onNext, Func<Exception, CancellationToken, ValueTask>? onErrorResume, Func<Result, ValueTask>? onCompleted)

View source

Summary: Invokes the specified asynchronous actions for each element, error, or completion notification in the observable sequence without modifying the sequence.

Type parameters

NameDescription
TThe type of elements in the source sequence.

Parameters

NameTypeDescription
this[IObservableAsync](#The source observable sequence.
onNextFunc?An asynchronous callback to invoke for each element in the sequence. Receives the element and a cancellation token. If null, no action is taken on elements.
onErrorResumeFunc?An optional asynchronous callback to invoke if an error occurs in the sequence. Receives the exception and a cancellation token. If null, errors are not handled by this observer.
onCompletedFunc?An optional asynchronous callback to invoke when the sequence completes. Receives the result of the sequence. If null, no action is taken on completion.

Returns: IObservableAsync -- An observable sequence that is identical to the source sequence but invokes the specified callbacks for side effects.

Remarks

Use this method to perform side effects such as logging, resource cleanup, or notification in response to elements, errors, or completion events in the sequence. The callbacks are invoked asynchronously and do not alter the elements or flow of the sequence.

2. Overload

public static IObservableAsync<T> Do<T>(this IObservableAsync<T> @this, Func<T, CancellationToken, ValueTask>? onNext)

View source

Summary: Invokes the specified asynchronous action for each element in the observable sequence without modifying the sequence.

Type parameters

NameDescription
TThe type of elements in the source sequence.

Parameters

NameTypeDescription
this[IObservableAsync](#The source observable sequence.
onNextFunc?An asynchronous callback to invoke for each element in the sequence. Receives the element and a cancellation token. If null, no action is taken on elements.

Returns: IObservableAsync -- An observable sequence that is identical to the source sequence but invokes the specified callback for side effects.

3. Overload

public static IObservableAsync<T> Do<T>(this IObservableAsync<T> @this, Action<T>? onNext, Action<Exception>? onErrorResume, Action<Result>? onCompleted)

View source

Summary: Invokes the specified actions in response to notifications from the observable sequence without modifying the sequence itself.

Type parameters

NameDescription
TThe type of elements in the source sequence.

Parameters

NameTypeDescription
this[IObservableAsync](#The source observable sequence.
onNextAction?An action to invoke for each element in the sequence as it is emitted. If null, no action is taken on element emission.
onErrorResumeAction?An action to invoke if an error occurs in the sequence. Receives the exception that caused the error. If null, no action is taken on error.
onCompletedAction?An action to invoke when the sequence completes, receiving the final result. If null, no action is taken on completion.

Returns: IObservableAsync -- An observable sequence that is identical to the source sequence but invokes the specified actions for each notification.

Remarks

Use this method to perform side effects such as logging, monitoring, or debugging in response to sequence events without altering the sequence's behavior. The returned observable passes through all elements and notifications unchanged.

4. Overload

public static IObservableAsync<T> Do<T>(this IObservableAsync<T> @this)

View source

Summary: Returns an observable sequence that is identical to the source sequence and performs no side effects.

Type parameters

NameDescription
TThe type of elements in the source sequence.

Parameters

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

Returns: IObservableAsync -- An observable sequence that is identical to the source sequence.