Class ReplaySubject<T>
Represents an object that is both an observable sequence as well as an observer. Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies.
Inherited Members
Namespace: System.Reactive.Subjects
Assembly: System.Reactive.Linq.dll
Syntax
public sealed class ReplaySubject<T> : ISubject<T>, ISubject<T, T>, IObserver<T>, IObservable<T>, IDisposable
Type Parameters
| Name | Description |
|---|---|
| T | The type of the elements processed by the subject. |
Constructors
| Improve this Doc View SourceReplaySubject()
Initializes a new instance of the ReplaySubject<T> class.
Declaration
public ReplaySubject()
ReplaySubject(Int32)
Initializes a new instance of the ReplaySubject<T> class with the specified buffer size.
Declaration
public ReplaySubject(int bufferSize)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | bufferSize | Maximum element count of the replay buffer. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
ReplaySubject(Int32, IScheduler)
Initializes a new instance of the ReplaySubject<T> class with the specified buffer size and scheduler.
Declaration
public ReplaySubject(int bufferSize, IScheduler scheduler)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | bufferSize | Maximum element count of the replay buffer. |
| IScheduler | scheduler | Scheduler the observers are invoked on. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
|
ReplaySubject(Int32, TimeSpan)
Initializes a new instance of the ReplaySubject<T> class with the specified buffer size and window.
Declaration
public ReplaySubject(int bufferSize, TimeSpan window)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | bufferSize | Maximum element count of the replay buffer. |
| TimeSpan | window | Maximum time length of the replay buffer. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
ReplaySubject(Int32, TimeSpan, IScheduler)
Initializes a new instance of the ReplaySubject<T> class with the specified buffer size, window and scheduler.
Declaration
public ReplaySubject(int bufferSize, TimeSpan window, IScheduler scheduler)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | bufferSize | Maximum element count of the replay buffer. |
| TimeSpan | window | Maximum time length of the replay buffer. |
| IScheduler | scheduler | Scheduler the observers are invoked on. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| ArgumentNullException |
|
ReplaySubject(IScheduler)
Initializes a new instance of the ReplaySubject<T> class with the specified scheduler.
Declaration
public ReplaySubject(IScheduler scheduler)
Parameters
| Type | Name | Description |
|---|---|---|
| IScheduler | scheduler | Scheduler the observers are invoked on. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
ReplaySubject(TimeSpan)
Initializes a new instance of the ReplaySubject<T> class with the specified window.
Declaration
public ReplaySubject(TimeSpan window)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | window | Maximum time length of the replay buffer. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
ReplaySubject(TimeSpan, IScheduler)
Initializes a new instance of the ReplaySubject<T> class with the specified window and scheduler.
Declaration
public ReplaySubject(TimeSpan window, IScheduler scheduler)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | window | Maximum time length of the replay buffer. |
| IScheduler | scheduler | Scheduler the observers are invoked on. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
|
Properties
| Improve this Doc View SourceHasObservers
Indicates whether the subject has observers subscribed to it.
Declaration
public bool HasObservers { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
Methods
| Improve this Doc View SourceDispose()
Releases all resources used by the current instance of the ReplaySubject<T> class and unsubscribe all observers.
Declaration
public void Dispose()
OnCompleted()
Notifies all subscribed and future observers about the end of the sequence.
Declaration
public void OnCompleted()
OnError(Exception)
Notifies all subscribed and future observers about the specified exception.
Declaration
public void OnError(Exception error)
Parameters
| Type | Name | Description |
|---|---|---|
| Exception | error | The exception to send to all observers. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
OnNext(T)
Notifies all subscribed and future observers about the arrival of the specified element in the sequence.
Declaration
public void OnNext(T value)
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | The value to send to all observers. |
Subscribe(IObserver<T>)
Subscribes an observer to the subject.
Declaration
public IDisposable Subscribe(IObserver<T> observer)
Parameters
| Type | Name | Description |
|---|---|---|
| IObserver<T> | observer | Observer to subscribe to the subject. |
Returns
| Type | Description |
|---|---|
| IDisposable | Disposable object that can be used to unsubscribe the observer from the subject. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|