Class SerialReplayLatestSubjectAsync<T>
- Namespace
- ReactiveUI.Extensions.Async.Subjects
- Assembly
- ReactiveUI.Extensions.dll
Represents an asynchronous subject that replays only the latest value to new subscribers and ensures that notifications are delivered to observers in a serial, thread-safe manner.
public sealed class SerialReplayLatestSubjectAsync<T> : BaseReplayLatestSubjectAsync<T>, ISubjectAsync<T>, IObserverAsync<T>, IAsyncDisposable, IObservableAsync<T>
Type Parameters
TThe type of the elements processed by the subject.
- Inheritance
-
SerialReplayLatestSubjectAsync<T>
- Implements
- Inherited Members
- Extension Methods
Remarks
This subject is designed for scenarios where only the most recent value is relevant to subscribers. When a new observer subscribes, it immediately receives the latest value (if any) and then all subsequent notifications. All observer notifications are performed asynchronously and in a serial order, ensuring thread safety. This type is suitable for use cases where replaying only the latest value is desired, such as event streams or state broadcasts.
Constructors
SerialReplayLatestSubjectAsync(Optional<T>)
Represents an asynchronous subject that replays only the latest value to new subscribers and ensures that notifications are delivered to observers in a serial, thread-safe manner.
public SerialReplayLatestSubjectAsync(Optional<T> startValue)
Parameters
startValueOptional<T>An optional initial value to be emitted to new subscribers before any other values are published.
Remarks
This subject is designed for scenarios where only the most recent value is relevant to subscribers. When a new observer subscribes, it immediately receives the latest value (if any) and then all subsequent notifications. All observer notifications are performed asynchronously and in a serial order, ensuring thread safety. This type is suitable for use cases where replaying only the latest value is desired, such as event streams or state broadcasts.
Methods
OnCompletedAsyncCore(IReadOnlyList<IObserverAsync<T>>, Result)
Notifies all specified observers that the asynchronous operation has completed, passing the provided 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 operation's completion. Cannot be null.
resultResultThe result to pass to each observer's completion handler.
Returns
- ValueTask
A task that represents the asynchronous notification operation.
OnErrorResumeAsyncCore(IReadOnlyList<IObserverAsync<T>>, Exception, CancellationToken)
Notifies each observer in the collection of an error and allows them to resume processing asynchronously.
protected override ValueTask OnErrorResumeAsyncCore(IReadOnlyList<IObserverAsync<T>> observers, Exception error, CancellationToken cancellationToken)
Parameters
observersIReadOnlyList<IObserverAsync<T>>A read-only list of observers to be notified of the error. Cannot be null.
errorExceptionThe exception that occurred. Cannot be null.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the asynchronous operation.
Returns
- ValueTask
A task that represents the asynchronous notification operation.
OnNextAsyncCore(IReadOnlyList<IObserverAsync<T>>, T, CancellationToken)
Asynchronously notifies each observer in the specified collection with the provided value.
protected override ValueTask OnNextAsyncCore(IReadOnlyList<IObserverAsync<T>> observers, T value, CancellationToken cancellationToken)
Parameters
observersIReadOnlyList<IObserverAsync<T>>A read-only list 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 task that represents the asynchronous notification operation.