Table of Contents

Class ConcurrentSubjectAsync<T>

Namespace
ReactiveUI.Extensions.Async.Subjects
Assembly
ReactiveUI.Extensions.dll

Provides an asynchronous subject that forwards notifications to observers concurrently.

public sealed class ConcurrentSubjectAsync<T> : BaseSubjectAsync<T>, ISubjectAsync<T>, IObserverAsync<T>, IAsyncDisposable, IObservableAsync<T>

Type Parameters

T

The type of value observed and forwarded to observers.

Inheritance
ConcurrentSubjectAsync<T>
Implements
Inherited Members
Extension Methods

Remarks

Observers are notified in parallel for each event. This class is suitable for scenarios where high throughput and concurrent notification of multiple observers are required. Thread safety is ensured for observer notification operations. Cancellation tokens can be used to cancel ongoing notification tasks.

Constructors

ConcurrentSubjectAsync()

public ConcurrentSubjectAsync()

Methods

OnCompletedAsyncCore(IReadOnlyList<IObserverAsync<T>>, Result)

Notifies all observers of the completion event asynchronously.

protected override ValueTask OnCompletedAsyncCore(IReadOnlyList<IObserverAsync<T>> observers, Result result)

Parameters

observers IReadOnlyList<IObserverAsync<T>>

A read-only list of observers to be notified of the completion event.

result Result

The result information to be provided to each observer upon completion.

Returns

ValueTask

A ValueTask that represents the asynchronous notification operation. The task completes when all observers have been notified.

Remarks

Observers are notified concurrently. If any observer throws an exception during notification, the exception may be aggregated and surfaced to the caller.

OnErrorResumeAsyncCore(IReadOnlyList<IObserverAsync<T>>, Exception, CancellationToken)

Handles an error by resuming asynchronous observation for each observer in the collection.

protected override ValueTask OnErrorResumeAsyncCore(IReadOnlyList<IObserverAsync<T>> observers, Exception error, CancellationToken cancellationToken)

Parameters

observers IReadOnlyList<IObserverAsync<T>>

A read-only list of observers to which the error handling and resumption logic will be applied.

error Exception

The exception that triggered the error handling process.

cancellationToken CancellationToken

A cancellation token that can be used to cancel the asynchronous operation.

Returns

ValueTask

A ValueTask representing the asynchronous operation of forwarding the error and resuming observation for all observers.

Remarks

This method processes all observers concurrently. If the operation is canceled via the provided cancellation token, the task will complete in a canceled state.

OnNextAsyncCore(IReadOnlyList<IObserverAsync<T>>, T, CancellationToken)

Forwards the specified value to all observers asynchronously.

protected override ValueTask OnNextAsyncCore(IReadOnlyList<IObserverAsync<T>> observers, T value, CancellationToken cancellationToken)

Parameters

observers IReadOnlyList<IObserverAsync<T>>

A read-only list of observers that will receive the value. Cannot be null.

value T

The value to be sent to each observer.

cancellationToken CancellationToken

A cancellation token that can be used to cancel the forwarding operation.

Returns

ValueTask

A ValueTask that represents the asynchronous forwarding operation.

Remarks

Observers are notified concurrently. If cancellation is requested, the operation may terminate before all observers are notified.