Interface IObserverAsync<T>
- Namespace
- ReactiveUI.Extensions.Async
- Assembly
- ReactiveUI.Extensions.dll
Defines an asynchronous observer that receives notifications about a sequence of values, completion, or errors, and supports asynchronous resource cleanup.
public interface IObserverAsync<T> : IAsyncDisposable
Type Parameters
TThe type of the elements received by the observer.
- Inherited Members
- Extension Methods
Remarks
Implementations of this interface allow for non-blocking, asynchronous handling of data streams, including support for cancellation and proper disposal of resources. This is useful in scenarios where observers need to process events or data asynchronously, such as in reactive or event-driven programming models.
Methods
OnCompletedAsync(Result)
Performs asynchronous completion logic in response to the specified result.
ValueTask OnCompletedAsync(Result result)
Parameters
resultResultThe result object that provides information about the completed operation. Cannot be null.
Returns
- ValueTask
A ValueTask that represents the asynchronous completion operation.
OnErrorResumeAsync(Exception, CancellationToken)
Handles the specified error and resumes asynchronous processing, if possible.
ValueTask OnErrorResumeAsync(Exception error, CancellationToken cancellationToken)
Parameters
errorExceptionThe exception that caused the error. Cannot be null.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the error handling operation.
Returns
- ValueTask
A ValueTask that represents the asynchronous error handling operation.
Remarks
Implementations may choose to suppress the error and continue processing, or perform cleanup and terminate gracefully. The behavior depends on the specific implementation.
OnNextAsync(T, CancellationToken)
Asynchronously processes the next value in the sequence.
ValueTask OnNextAsync(T value, CancellationToken cancellationToken)
Parameters
valueTThe value to be processed.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the asynchronous operation.
Returns
- ValueTask
A task that represents the asynchronous operation.