Class ConcurrentReplayLatestSubjectAsync<T>
- Namespace
- ReactiveUI.Extensions.Async.Subjects
- Assembly
- ReactiveUI.Extensions.dll
Represents an asynchronous subject that replays only the latest value to new observers and supports concurrent notification of observers.
public sealed class ConcurrentReplayLatestSubjectAsync<T> : BaseReplayLatestSubjectAsync<T>, ISubjectAsync<T>, IObserverAsync<T>, IAsyncDisposable, IObservableAsync<T>
Type Parameters
TThe type of the elements processed by the subject.
- Inheritance
-
ConcurrentReplayLatestSubjectAsync<T>
- Implements
- Inherited Members
- Extension Methods
Remarks
This subject notifies all observers concurrently, which can improve throughput in scenarios with multiple observers. The order in which observers receive notifications is not guaranteed. This type is thread-safe and suitable for use in asynchronous and concurrent environments.
Constructors
ConcurrentReplayLatestSubjectAsync(Optional<T>)
Represents an asynchronous subject that replays only the latest value to new observers and supports concurrent notification of observers.
public ConcurrentReplayLatestSubjectAsync(Optional<T> startValue)
Parameters
startValueOptional<T>An optional initial value to be emitted to observers upon subscription if no other value has been published.
Remarks
This subject notifies all observers concurrently, which can improve throughput in scenarios with multiple observers. The order in which observers receive notifications is not guaranteed. This type is thread-safe and suitable for use in asynchronous and concurrent environments.
Methods
OnCompletedAsyncCore(IReadOnlyList<IObserverAsync<T>>, Result)
Notifies all observers that the asynchronous operation has completed, forwarding the specified result to each observer.
protected override ValueTask OnCompletedAsyncCore(IReadOnlyList<IObserverAsync<T>> observers, Result result)
Parameters
observersIReadOnlyList<IObserverAsync<T>>A read-only list of observers to be notified of the completion event. Cannot be null.
resultResultThe result to forward to each observer upon completion.
Returns
- ValueTask
A ValueTask that represents the asynchronous notification operation.
Remarks
Observers are notified concurrently. The method does not guarantee the order in which observers are notified.
OnErrorResumeAsyncCore(IReadOnlyList<IObserverAsync<T>>, Exception, CancellationToken)
Asynchronously notifies all observers of an error and resumes processing, if possible.
protected override ValueTask OnErrorResumeAsyncCore(IReadOnlyList<IObserverAsync<T>> observers, Exception error, CancellationToken cancellationToken)
Parameters
observersIReadOnlyList<IObserverAsync<T>>The collection of observers to be notified of the error. Cannot be null.
errorExceptionThe exception that occurred. Cannot be null.
cancellationTokenCancellationTokenA token that can be used to cancel the asynchronous operation.
Returns
- ValueTask
A ValueTask that represents the asynchronous notification operation.
OnNextAsyncCore(IReadOnlyList<IObserverAsync<T>>, T, CancellationToken)
Asynchronously notifies all observers in the collection with the specified value.
protected override ValueTask OnNextAsyncCore(IReadOnlyList<IObserverAsync<T>> observers, T value, CancellationToken cancellationToken)
Parameters
observersIReadOnlyList<IObserverAsync<T>>The collection of observers to be notified. Cannot be null.
valueTThe value to send to each observer.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the notification operation.
Returns
- ValueTask
A ValueTask that represents the asynchronous notification operation.