Skip to content

,System.Func{System.Threading.Tasks.ValueTask})} ,System.Action)}

ObservableAsync.OnDispose(IObservableAsync, 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> OnDispose<T>(this IObservableAsync<T> @this, Func<ValueTask> disposeAction)
  • 2. public static IObservableAsync<T> OnDispose<T>(this IObservableAsync<T> @this, Action disposeAction)

1. Overload

public static IObservableAsync<T> OnDispose<T>(this IObservableAsync<T> @this, Func<ValueTask> disposeAction)

View source

Summary: Registers a callback to be invoked asynchronously when the observable sequence is disposed.

Type parameters

NameDescription
TThe type of elements in the source sequence.

Parameters

NameTypeDescription
this[IObservableAsync](#The source observable sequence.
disposeActionFuncA function that returns a ValueTask representing the asynchronous operation to execute upon disposal of the observable sequence. Cannot be null.

Returns: IObservableAsync -- An ObservableAsync that invokes the specified asynchronous callback when disposed.

Remarks

Use this method to perform custom asynchronous cleanup or resource release logic when the observable sequence is disposed. The callback is invoked when the subscription is disposed, either explicitly or when the observer completes or errors.

2. Overload

public static IObservableAsync<T> OnDispose<T>(this IObservableAsync<T> @this, Action disposeAction)

View source

Summary: Registers an action to be invoked when the observable sequence is disposed.

Type parameters

NameDescription
TThe type of elements in the source sequence.

Parameters

NameTypeDescription
this[IObservableAsync](#The source observable sequence.
disposeActionActionThe action to execute when the subscription is disposed. Cannot be null.

Returns: IObservableAsync -- An observable sequence that invokes the specified action upon disposal of the subscription.

Remarks

Use this method to perform cleanup or resource release logic when a subscription to the observable is disposed. The specified action is called synchronously during disposal. If multiple actions are registered through chained calls, each will be invoked in the order registered.