Table of Contents

Class SubjectAsync

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

Provides factory methods for creating asynchronous subject instances with configurable publishing and state retention behaviors.

public static class SubjectAsync
Inheritance
SubjectAsync

Remarks

The SubjectAsync class offers a variety of static methods to create subjects that support different publishing strategies (such as serial or concurrent) and state management options (stateful or stateless). These subjects can be used to broadcast values to multiple observers in asynchronous scenarios. Use the provided creation options to customize the subject's behavior according to your application's requirements.

Methods

CreateBehavior<T>(T)

Creates a new asynchronous behavior subject initialized with the specified starting value.

public static ISubjectAsync<T> CreateBehavior<T>(T startValue)

Parameters

startValue T

The initial value to be emitted to new subscribers and stored as the current value of the subject.

Returns

ISubjectAsync<T>

An asynchronous behavior subject that holds the specified starting value and emits it to new subscribers.

Type Parameters

T

The type of the elements processed by the subject.

CreateBehavior<T>(T, BehaviorSubjectCreationOptions)

Creates a new asynchronous subject that replays the latest value to new subscribers, using the specified initial value and creation options.

public static ISubjectAsync<T> CreateBehavior<T>(T startValue, BehaviorSubjectCreationOptions options)

Parameters

startValue T

The initial value to be published by the subject before any values are pushed.

options BehaviorSubjectCreationOptions

The options that control the subject's publishing behavior and state management.

Returns

ISubjectAsync<T>

An asynchronous subject that replays the latest value to new subscribers, configured according to the specified options.

Type Parameters

T

The type of the values published by the subject.

Exceptions

ArgumentOutOfRangeException

Thrown if the specified options contain an unsupported publishing configuration.

CreateReplayLatest<T>()

Creates a new asynchronous subject that replays only the most recent value to new subscribers.

public static ISubjectAsync<T> CreateReplayLatest<T>()

Returns

ISubjectAsync<T>

An asynchronous subject that stores and replays the latest value to each new subscriber.

Type Parameters

T

The type of the elements processed by the subject.

Remarks

The returned subject will only retain the most recent value published. When a new subscriber subscribes, it immediately receives the latest value, if any, followed by subsequent values. This is useful for scenarios where only the most recent state is relevant to new observers.

CreateReplayLatest<T>(ReplayLatestSubjectCreationOptions)

Creates a new asynchronous subject that replays the latest value to new subscribers, with configuration options for publishing behavior and statefulness.

public static ISubjectAsync<T> CreateReplayLatest<T>(ReplayLatestSubjectCreationOptions options)

Parameters

options ReplayLatestSubjectCreationOptions

The options that specify the publishing mode and whether the subject maintains state. Cannot be null.

Returns

ISubjectAsync<T>

An asynchronous subject that replays the latest value to new subscribers, configured according to the specified options.

Type Parameters

T

The type of the elements processed by the subject.

Exceptions

ArgumentOutOfRangeException

Thrown if the combination of options specified in the options parameter is not supported.

Create<T>()

Creates a new asynchronous subject instance for the specified type.

public static ISubjectAsync<T> Create<T>()

Returns

ISubjectAsync<T>

An ISubjectAsync<T> that represents the newly created asynchronous subject.

Type Parameters

T

The type of elements processed by the subject.

Remarks

The created subject uses the default subject creation options. Use the overload that accepts SubjectCreationOptions to customize subject behavior.

Create<T>(SubjectCreationOptions)

Creates a new asynchronous subject instance with the specified publishing and state options.

public static ISubjectAsync<T> Create<T>(SubjectCreationOptions options)

Parameters

options SubjectCreationOptions

The options that configure the publishing behavior and statefulness of the subject. Must specify valid values for publishing and statelessness.

Returns

ISubjectAsync<T>

An asynchronous subject instance configured according to the specified options.

Type Parameters

T

The type of elements processed by the subject.

Remarks

Use this method to create an ISubjectAsync{T} with the desired concurrency and state management characteristics. The returned subject type depends on the values provided in the options parameter.

Exceptions

ArgumentOutOfRangeException

Thrown if the specified combination of publishing and statelessness options is not supported.