Share via


ReplaySubject<T> Class

Represents an object that is both an observable sequence as well as an observer.

Inheritance Hierarchy

System.Object
  System.Reactive.Subjects.ReplaySubject<T>

Namespace:  System.Reactive.Subjects
Assembly:  System.Reactive (in System.Reactive.dll)

Syntax

'Declaration
Public NotInheritable Class ReplaySubject(Of T) _
    Implements ISubject(Of T), ISubject(Of T, T),  _
    IObserver(Of T), IObservable(Of T), IDisposable
'Usage
Dim instance As ReplaySubject(Of T)
public sealed class ReplaySubject<T> : ISubject<T>, 
    ISubject<T, T>, IObserver<T>, IObservable<T>, IDisposable
generic<typename T>
public ref class ReplaySubject sealed : ISubject<T>, 
    ISubject<T, T>, IObserver<T>, IObservable<T>, IDisposable
[<SealedAttribute>]
type ReplaySubject<'T> =  
    class
        interface ISubject<'T>
        interface ISubject<'T, 'T>
        interface IObserver<'T>
        interface IObservable<'T>
        interface IDisposable
    end
JScript does not support generic types and methods.

Type Parameters

  • T
    The type.

The ReplaySubject<T> type exposes the following members.

Constructors

  Name Description
Public method ReplaySubject<T>() Creates a replayable subject.
Public method ReplaySubject<T>(Int32) Initializes a new instance of the ReplaySubject<T> class with the specified buffer size.
Public method ReplaySubject<T>(TimeSpan) Initializes a new instance of the ReplaySubject<T> class with the specified window.
Public method ReplaySubject<T>(IScheduler) Initializes a new instance of the ReplaySubject<T> class with the specified scheduler.
Public method ReplaySubject<T>(Int32, IScheduler) Initializes a new instance of the ReplaySubject<T> class with the specified buffer size and scheduler.
Public method ReplaySubject<T>(Int32, TimeSpan) Initializes a new instance of the ReplaySubject<T> class with the specified buffer size and window.
Public method ReplaySubject<T>(TimeSpan, IScheduler) Initializes a new instance of the ReplaySubject<T> class with the specified window and scheduler.
Public method ReplaySubject<T>(Int32, TimeSpan, IScheduler) Initializes a new instance of the ReplaySubject<T> class with the specified buffer size, window and scheduler.

Top

Methods

  Name Description
Public method Dispose Releases all resources used by the current instance of the ReplaySubject<T> class and unsubscribe all observers.
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GetHashCode (Inherited from Object.)
Public method GetType (Inherited from Object.)
Protected method MemberwiseClone (Inherited from Object.)
Public method OnCompleted Notifies all subscribed observers of the end of the sequence.
Public method OnError Notifies all subscribed observers with the exception.
Public method OnNext Notifies all subscribed observers with the value.
Public method Subscribe Subscribes an observer to the subject.
Public method ToString (Inherited from Object.)

Top

Extension Methods

  Name Description
Public Extension Method Aggregate<T>(Func<T, T, T>) Overloaded. Applies an accumulator function over an observable sequence. (Defined by Observable.)
Public Extension Method Aggregate<T, TAccumulate>(TAccumulate, Func<TAccumulate, T, TAccumulate>) Overloaded. Applies an accumulator function over an observable sequence with the specified seed value. (Defined by Observable.)
Public Extension Method All<T> Determines whether all elements of an observable sequence satisfies a condition. (Defined by Observable.)
Public Extension Method Amb<T> Propagates the observable sequence that reacts first with the specified first and second sequence. (Defined by Observable.)
Public Extension Method And<T, TRight> Matches when both observable sequences have an available value. (Defined by Observable.)
Public Extension Method Any<T>() Overloaded. Determines whether an observable sequence contains any elements. (Defined by Observable.)
Public Extension Method Any<T>(Func<T, Boolean>) Overloaded. Determines whether all elements of an observable sequence satisfies a condition. (Defined by Observable.)
Public Extension Method AsObservable<T> Hides the identity of an observable sequence. (Defined by Observable.)
Public Extension Method AsObserver<T> Hides the identity of an observer. (Defined by Observer.)
Public Extension Method AsQbservable<T> Converts an observable sequence into a queryable observable sequence. (Defined by Qbservable.)
Public Extension Method AssertEqual<T> (Defined by Extensions.)
Public Extension Method Buffer<T>(Int32) Overloaded. Indicates each element of an observable sequence into consecutive non-overlapping buffers which are produced based on element count information. (Defined by Observable.)
Public Extension Method Buffer<T>(TimeSpan) Overloaded. Indicates each element of an observable sequence into consecutive non-overlapping buffers which are produced based on timing information. (Defined by Observable.)
Public Extension Method Buffer<T>(Int32, Int32) Overloaded. Indicates each element of an observable sequence into zero or more buffers which are produced based on element count information. (Defined by Observable.)
Public Extension Method Buffer<T>(TimeSpan, IScheduler) Overloaded. Indicates each element of an observable sequence into consecutive non-overlapping buffers which are produced based on timing information. (Defined by Observable.)
Public Extension Method Buffer<T>(TimeSpan, TimeSpan) Overloaded. Indicates each element of an observable sequence into zero or more buffers which are produced based on timing information. (Defined by Observable.)
Public Extension Method Buffer<T>(TimeSpan, Int32) Overloaded. Indicates each element of an observable sequence into a buffer that’s sent out when either it’s full or a given amount of time has elapsed. (Defined by Observable.)
Public Extension Method Buffer<T>(TimeSpan, TimeSpan, IScheduler) Overloaded. Indicates each element of an observable sequence into zero or more buffers which are produced based on timing information. (Defined by Observable.)
Public Extension Method Buffer<T>(TimeSpan, Int32, IScheduler) Overloaded. Indicates each element of an observable sequence into a buffer that’s sent out when either it’s full or a given amount of time has elapsed. (Defined by Observable.)
Public Extension Method Buffer<T, TBufferClosing>(Func<IObservable<TBufferClosing>>) Overloaded. Indicates each element of an observable sequence into consecutive non-overlapping buffers. (Defined by Observable.)
Public Extension Method Buffer<T, TBufferOpening, TBufferClosing>(IObservable<TBufferOpening>, Func<TBufferOpening, IObservable<TBufferClosing>>) Overloaded. Indicates each element of a queryable observable sequence into consecutive non-overlapping buffers. (Defined by Observable.)
Public Extension Method Catch<T>(IObservable<T>) Overloaded. Continues an observable sequence that is terminated by an exception with the next observable sequence. (Defined by Observable.)
Public Extension Method Catch<T, TException>(Func<TException, IObservable<T>>) Overloaded. Continues an observable sequence that is terminated by an exception of the specified type with the observable sequence produced by the handler. (Defined by Observable.)
Public Extension Method CombineLatest<T, TSecond, TResult> Merges two observable sequences into one observable sequence by using the selector function whenever one of the observable sequences produces an element. (Defined by Observable.)
Public Extension Method Concat<T> Concatenates two observable sequences. (Defined by Observable.)
Public Extension Method Contains<T>(T) Overloaded. Determines whether an observable sequence contains a specified element by using the default equality comparer. (Defined by Observable.)
Public Extension Method Contains<T>(T, IEqualityComparer<T>) Overloaded. Determines whether an observable sequence contains a specified element by using a specified System.Collections.Generic.IEqualityComparer&lt;T&gt;. (Defined by Observable.)
Public Extension Method Count<T> Returns a Int32 that represents the total number of elements in an observable sequence. (Defined by Observable.)
Public Extension Method DefaultIfEmpty<T>() Overloaded. Returns the elements of the specified sequence or the type parameter's default value in a singleton sequence if the sequence is empty. (Defined by Observable.)
Public Extension Method DefaultIfEmpty<T>(T) Overloaded. Returns the elements of the specified sequence or the type parameter's default value in a singleton sequence if the sequence is empty. (Defined by Observable.)
Public Extension Method Delay<T>(TimeSpan) Overloaded. Indicates the observable sequence by due time with the specified source and dueTime. (Defined by Observable.)
Public Extension Method Delay<T>(DateTimeOffset) Overloaded. Indicates the observable sequence by due time with the specified source and dueTime. (Defined by Observable.)
Public Extension Method Delay<T>(TimeSpan, IScheduler) Overloaded. Indicates the observable sequence by due time with the specified source, dueTime and scheduler. (Defined by Observable.)
Public Extension Method Delay<T>(DateTimeOffset, IScheduler) Overloaded. Indicates the observable sequence by due time with the specified source, dueTime and scheduler. (Defined by Observable.)
Public Extension Method Distinct<T>() Overloaded. Returns an observable sequence that contains only distinct elements with a specified source. (Defined by Observable.)
Public Extension Method Distinct<T>(IEqualityComparer<T>) Overloaded. Returns an observable sequence that contains only distinct elements according to the comparer. (Defined by Observable.)
Public Extension Method Distinct<T, TKey>(Func<T, TKey>) Overloaded. Returns an observable sequence that contains only distinct elements according to the keySelector. (Defined by Observable.)
Public Extension Method Distinct<T, TKey>(Func<T, TKey>, IEqualityComparer<TKey>) Overloaded. Returns an observable sequence that contains only distinct elements according to the keySelector. (Defined by Observable.)
Public Extension Method DistinctUntilChanged<T>() Overloaded. Returns an observable sequence that contains only distinct contiguous elements with a specified source. (Defined by Observable.)
Public Extension Method DistinctUntilChanged<T>(IEqualityComparer<T>) Overloaded. Returns an observable sequence that contains only distinct contiguous elements according to the comparer. (Defined by Observable.)
Public Extension Method DistinctUntilChanged<T, TKey>(Func<T, TKey>) Overloaded. Returns an observable sequence that contains only distinct contiguous elements according to the keySelector. (Defined by Observable.)
Public Extension Method DistinctUntilChanged<T, TKey>(Func<T, TKey>, IEqualityComparer<TKey>) Overloaded. Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer. (Defined by Observable.)
Public Extension Method Do<T>(Action<T>) Overloaded. Invokes an action for each element in the observable sequence. (Defined by Observable.)
Public Extension Method Do<T>(IObserver<T>) Overloaded. Invokes an action for each element in the observable sequence and invokes an action upon exceptional termination of the observable sequence. (Defined by Observable.)
Public Extension Method Do<T>(Action<T>, Action) Overloaded. Invokes an action for each element in the observable sequence and invokes an action upon graceful termination of the observable sequence. (Defined by Observable.)
Public Extension Method Do<T>(Action<T>, Action<Exception>) Overloaded. Invokes an action for each element in the observable sequence and invokes an action upon exceptional termination of the observable sequence. (Defined by Observable.)
Public Extension Method Do<T>(Action<T>, Action<Exception>, Action) Overloaded. Invokes an action for each element in the observable sequence, and invokes an action upon graceful or exceptional termination of the observable sequence. (Defined by Observable.)
Public Extension Method ElementAt<T> Returns the element at a specified index in a sequence. (Defined by Observable.)
Public Extension Method ElementAtOrDefault<T> Returns the element at a specified index in a sequence or a default value if the index is out of range. (Defined by Observable.)
Public Extension Method Finally<T> Invokes a specified action after source observable sequence terminates normally or by an exception. (Defined by Observable.)
Public Extension Method First<T>() Overloaded. Returns the first element of an observable sequence with a specified source. (Defined by Observable.)
Public Extension Method First<T>(Func<T, Boolean>) Overloaded. Returns the first element of an observable sequence that matches the predicate. (Defined by Observable.)
Public Extension Method FirstOrDefault<T>() Overloaded. Returns the first element of an observable sequence, or a default value if no value is found. (Defined by Observable.)
Public Extension Method FirstOrDefault<T>(Func<T, Boolean>) Overloaded. Returns the first element of an observable sequence that matches the predicate, or a default value if no value is found. (Defined by Observable.)
Public Extension Method Foo<T, R> (Defined by MyExt.)
Public Extension Method ForEach<T> Invokes an action for each element in the observable sequence, and blocks until the sequence is terminated. (Defined by Observable.)
Public Extension Method GetEnumerator<T> Returns an enumerator that enumerates all values of the observable sequence. (Defined by Observable.)
Public Extension Method GroupBy<T, TKey>(Func<T, TKey>) Overloaded. Groups the elements of an observable sequence according to a specified key selector function. (Defined by Observable.)
Public Extension Method GroupBy<T, TKey>(Func<T, TKey>, IEqualityComparer<TKey>) Overloaded. Groups the elements of an observable sequence according to a specified key selector function and comparer. (Defined by Observable.)
Public Extension Method GroupBy<T, TKey, TElement>(Func<T, TKey>, Func<T, TElement>) Overloaded. Groups the elements of an observable sequence and selects the resulting elements by using a specified function. (Defined by Observable.)
Public Extension Method GroupBy<T, TKey, TElement>(Func<T, TKey>, Func<T, TElement>, IEqualityComparer<TKey>) Overloaded. Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function. (Defined by Observable.)
Public Extension Method GroupByUntil<T, TKey, TDuration>(Func<T, TKey>, Func<IGroupedObservable<TKey, T>, IObservable<TDuration>>) Overloaded. Groups the elements of an observable sequence according to a specified key selector function. (Defined by Observable.)
Public Extension Method GroupByUntil<T, TKey, TDuration>(Func<T, TKey>, Func<IGroupedObservable<TKey, T>, IObservable<TDuration>>, IEqualityComparer<TKey>) Overloaded. Groups the elements of an observable sequence according to a specified key selector function and comparer. (Defined by Observable.)
Public Extension Method GroupByUntil<T, TKey, TElement, TDuration>(Func<T, TKey>, Func<T, TElement>, Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>) Overloaded. Groups the elements of an observable sequence according to a specified key selector function and selects the resulting elements by using a specified function. (Defined by Observable.)
Public Extension Method GroupByUntil<T, TKey, TElement, TDuration>(Func<T, TKey>, Func<T, TElement>, Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>, IEqualityComparer<TKey>) Overloaded. Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function. (Defined by Observable.)
Public Extension Method GroupJoin<T, TRight, TLeftDuration, TRightDuration, TResult> Correlates the elements of two sequences based on overlapping durations, and groups the results. (Defined by Observable.)
Public Extension Method IgnoreElements<T> Ignores all values in an observable sequence leaving only the termination messages. (Defined by Observable.)
Public Extension Method Join<T, TRight, TLeftDuration, TRightDuration, TResult> Correlates the elements of two sequences based on overlapping durations. (Defined by Observable.)
Public Extension Method Last<T>() Overloaded. Returns the last element of an observable sequence with a specified source. (Defined by Observable.)
Public Extension Method Last<T>(Func<T, Boolean>) Overloaded. Returns the last element of an observable sequence that matches the predicate. (Defined by Observable.)
Public Extension Method LastOrDefault<T>() Overloaded. Returns last element in the observable sequence, or a default value if no value is found. (Defined by Observable.)
Public Extension Method LastOrDefault<T>(Func<T, Boolean>) Overloaded. Returns the last element of an observable sequence that matches the predicate, or a default value if no value is found. (Defined by Observable.)
Public Extension Method Latest<T> Samples the most recent value in an observable sequence. (Defined by Observable.)
Public Extension Method LongCount<T> Returns a Int64 that represents the total number of elements in an observable sequence. (Defined by Observable.)
Public Extension Method Materialize<T> Materializes the implicit notifications of an observable sequence as explicit notification values. (Defined by Observable.)
Public Extension Method Max<T>() Overloaded. Returns the maximum element in an observable sequence. (Defined by Observable.)
Public Extension Method Max<T>(IComparer<T>) Overloaded. Returns the maximum value in an observable sequence according to the specified comparer. (Defined by Observable.)
Public Extension Method MaxBy<T, TKey>(Func<T, TKey>) Overloaded. Returns the elements in an observable sequence with the maximum key value. (Defined by Observable.)
Public Extension Method MaxBy<T, TKey>(Func<T, TKey>, IComparer<TKey>) Overloaded. Returns the elements in an observable sequence with the maximum key value. (Defined by Observable.)
Public Extension Method Merge<T>(IObservable<T>) Overloaded. Merges an observable sequence of observable sequences into an observable sequence. (Defined by Observable.)
Public Extension Method Merge<T>(IObservable<T>, IScheduler) Overloaded. Merges two observable sequences into a single observable sequence. (Defined by Observable.)
Public Extension Method Min<T>() Overloaded. Returns the minimum element in an observable sequence. (Defined by Observable.)
Public Extension Method Min<T>(IComparer<T>) Overloaded. Returns the minimum value in an observable sequence according to the specified comparer. (Defined by Observable.)
Public Extension Method MinBy<T, TKey>(Func<T, TKey>) Overloaded. Returns the elements in an observable sequence with the minimum key value. (Defined by Observable.)
Public Extension Method MinBy<T, TKey>(Func<T, TKey>, IComparer<TKey>) Overloaded. Returns the elements in an observable sequence with the minimum key value according to the specified comparer. (Defined by Observable.)
Public Extension Method MostRecent<T> Samples the most recent value in an observable sequence. (Defined by Observable.)
Public Extension Method Multicast<T, TResult>(ISubject<T, TResult>) Overloaded. Returns a connectable observable sequence that upon connection causes the source sequence to push results into the specified subject. (Defined by Observable.)
Public Extension Method Multicast<T, TIntermediate, TResult>(Func<ISubject<T, TIntermediate>>, Func<IObservable<TIntermediate>, IObservable<TResult>>) Overloaded. Returns an observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. (Defined by Observable.)
Public Extension Method Next<T> Samples the next value (blocking without buffering) from in an observable sequence. (Defined by Observable.)
Public Extension Method ObserveOn<T>(SynchronizationContext) Overloaded. Asynchronously notify observers on the specified synchronization context. (Defined by Observable.)
Public Extension Method ObserveOn<T>(Control) Overloaded. (Defined by ControlObservable.)
Public Extension Method ObserveOn<T>(Dispatcher) Overloaded. (Defined by DispatcherObservable.)
Public Extension Method ObserveOn<T>(DispatcherScheduler) Overloaded. (Defined by DispatcherObservable.)
Public Extension Method ObserveOn<T>(IScheduler) Overloaded. Asynchronously notify observers on the specified scheduler. (Defined by Observable.)
Public Extension Method ObserveOnDispatcher<T> (Defined by DispatcherObservable.)
Public Extension Method OnErrorResumeNext<T> Continues an observable sequence that is terminated normally or by an exception with the next observable sequence. (Defined by Observable.)
Public Extension Method Publish<T>() Overloaded. Returns a connectable observable sequence that shares a single subscription to the underlying sequence. (Defined by Observable.)
Public Extension Method Publish<T>(T) Overloaded. Returns a connectable observable sequence that shares a single subscription to the underlying sequence and starts with initialValue. (Defined by Observable.)
Public Extension Method Publish<T, TResult>(Func<IObservable<T>, IObservable<TResult>>) Overloaded. Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence. (Defined by Observable.)
Public Extension Method Publish<T, TResult>(Func<IObservable<T>, IObservable<TResult>>, T) Overloaded. Returns a connectable observable sequence that shares a single subscription to the underlying sequence and starts with initialValue. (Defined by Observable.)
Public Extension Method PublishLast<T>() Overloaded. Returns a connectable observable sequence that shares a single subscription to the underlying sequence containing only the last notification. (Defined by Observable.)
Public Extension Method PublishLast<T, TResult>(Func<IObservable<T>, IObservable<TResult>>) Overloaded. Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence containing only the last notification. (Defined by Observable.)
Public Extension Method Repeat<T>() Overloaded. Repeats the observable sequence indefinitely. (Defined by Observable.)
Public Extension Method Repeat<T>(Int32) Overloaded. Repeats the observable sequence indefinitely. (Defined by Observable.)
Public Extension Method Replay<T>() Overloaded. Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying all notifications. (Defined by Observable.)
Public Extension Method Replay<T>(TimeSpan) Overloaded. Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying all notifications within window. (Defined by Observable.)
Public Extension Method Replay<T>(Int32) Overloaded. Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying bufferSize notifications. (Defined by Observable.)
Public Extension Method Replay<T>(IScheduler) Overloaded. Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying all notifications. (Defined by Observable.)
Public Extension Method Replay<T>(TimeSpan, IScheduler) Overloaded. Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying all notifications within window. (Defined by Observable.)
Public Extension Method Replay<T>(Int32, IScheduler) Overloaded. Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying bufferSize notifications. (Defined by Observable.)
Public Extension Method Replay<T>(Int32, TimeSpan) Overloaded. Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying bufferSize notifications within window. (Defined by Observable.)
Public Extension Method Replay<T>(Int32, TimeSpan, IScheduler) Overloaded. Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying bufferSize notifications within window. (Defined by Observable.)
Public Extension Method Replay<T, TResult>(Func<IObservable<T>, IObservable<TResult>>) Overloaded. Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence and starts with initial value. (Defined by Observable.)
Public Extension Method Replay<T, TResult>(Func<IObservable<T>, IObservable<TResult>>, IScheduler) Overloaded. Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying all notifications. (Defined by Observable.)
Public Extension Method Replay<T, TResult>(Func<IObservable<T>, IObservable<TResult>>, TimeSpan) Overloaded. Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying all notifications within window. (Defined by Observable.)
Public Extension Method Replay<T, TResult>(Func<IObservable<T>, IObservable<TResult>>, Int32) Overloaded. Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying bufferSize notifications. (Defined by Observable.)
Public Extension Method Replay<T, TResult>(Func<IObservable<T>, IObservable<TResult>>, TimeSpan, IScheduler) Overloaded. Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying all notifications within window. (Defined by Observable.)
Public Extension Method Replay<T, TResult>(Func<IObservable<T>, IObservable<TResult>>, Int32, IScheduler) Overloaded. Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying bufferSize notifications. (Defined by Observable.)
Public Extension Method Replay<T, TResult>(Func<IObservable<T>, IObservable<TResult>>, Int32, TimeSpan) Overloaded. Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying bufferSize notifications within window. (Defined by Observable.)
Public Extension Method Replay<T, TResult>(Func<IObservable<T>, IObservable<TResult>>, Int32, TimeSpan, IScheduler) Overloaded. Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying bufferSize notifications within window. (Defined by Observable.)
Public Extension Method Retry<T>() Overloaded. Repeats the source observable sequence until it successfully terminates. (Defined by Observable.)
Public Extension Method Retry<T>(Int32) Overloaded. Repeats the source observable sequence until it successfully terminates. (Defined by Observable.)
Public Extension Method Sample<T>(TimeSpan) Overloaded. Samples the observable sequence at each interval. (Defined by Observable.)
Public Extension Method Sample<T>(TimeSpan, IScheduler) Overloaded. Samples the observable sequence at each interval with the specified source, interval and scheduler. (Defined by Observable.)
Public Extension Method Sample<T, TSample>(IObservable<TSample>) Overloaded. Samples the observable sequence at sampling ticks with the specified source and sampler. (Defined by Observable.)
Public Extension Method Scan<T>(Func<T, T, T>) Overloaded. Applies an accumulator function over an observable sequence and returns each intermediate result with the specified source and accumulator. (Defined by Observable.)
Public Extension Method Scan<T, TAccumulate>(TAccumulate, Func<TAccumulate, T, TAccumulate>) Overloaded. Applies an accumulator function over an observable sequence and returns each intermediate result with the specified source, seed and accumulator. (Defined by Observable.)
Public Extension Method Select<T, TResult>(Func<T, TResult>) Overloaded. Projects each element of an observable sequence into a new form with the specified source and selector. (Defined by Observable.)
Public Extension Method Select<T, TResult>(Func<T, Int32, TResult>) Overloaded. Projects each element of an observable sequence into a new form by incorporating the element’s index with the specified source and selector. (Defined by Observable.)
Public Extension Method SelectMany<T, TOther>(IObservable<TOther>) Overloaded. Projects each element of an observable sequence to an observable sequence and flattens the resulting observable sequences into one observable sequence. (Defined by Observable.)
Public Extension Method SelectMany<T, TResult>(Func<T, IObservable<TResult>>) Overloaded. Projects each element of an observable sequence to an observable sequence and flattens the resulting observable sequences into one observable sequence. (Defined by Observable.)
Public Extension Method SelectMany<T, TResult>(Func<T, IEnumerable<TResult>>) Overloaded. Projects each element of an observable sequence to an observable sequence and flattens the resulting observable sequences into one observable sequence. (Defined by Observable.)
Public Extension Method SelectMany<T, TResult>(Func<T, IObservable<TResult>>, Func<Exception, IObservable<TResult>>, Func<IObservable<TResult>>) Overloaded. Projects each element of an observable sequence to an observable sequence and flattens the resulting observable sequences into one observable sequence. (Defined by Observable.)
Public Extension Method SelectMany<T, TCollection, TResult>(Func<T, IEnumerable<TCollection>>, Func<T, TCollection, TResult>) Overloaded. Projects each element of an observable sequence to an observable sequence and flattens the resulting observable sequences into one observable sequence. (Defined by Observable.)
Public Extension Method SelectMany<T, TCollection, TResult>(Func<T, IObservable<TCollection>>, Func<T, TCollection, TResult>) Overloaded. Projects each element of an observable sequence to an observable sequence and flattens the resulting observable sequences into one observable sequence. (Defined by Observable.)
Public Extension Method SequenceEqual<T>(IObservable<T>) Overloaded. Determines whether two sequences are equal by comparing the elements pairwise. (Defined by Observable.)
Public Extension Method SequenceEqual<T>(IObservable<T>, IEqualityComparer<T>) Overloaded. Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer. (Defined by Observable.)
Public Extension Method Single<T>() Overloaded. Returns the only element of an observable sequence and throws an exception if there is not exactly one element in the observable sequence. (Defined by Observable.)
Public Extension Method Single<T>(Func<T, Boolean>) Overloaded. Returns the only element of an observable sequence that matches the predicate and throws an exception if there is not exactly one element in the observable sequence. (Defined by Observable.)
Public Extension Method SingleOrDefault<T>() Overloaded. Returns the only element of an observable sequence, or a default value if the observable sequence is empty. (Defined by Observable.)
Public Extension Method SingleOrDefault<T>(Func<T, Boolean>) Overloaded. Returns the only element of an observable sequence that matches the predicate, or a default value if no value is found. (Defined by Observable.)
Public Extension Method Skip<T> Bypasses a specified number of values in an observable sequence and then returns the remaining values. (Defined by Observable.)
Public Extension Method SkipLast<T> Bypasses a specified number of elements at the end of an observable sequence. (Defined by Observable.)
Public Extension Method SkipUntil<T, TOther> Returns the values from the source observable sequence only after the other observable sequence produces a value. (Defined by Observable.)
Public Extension Method SkipWhile<T>(Func<T, Boolean>) Overloaded. Bypasses values in an observable sequence as long as a specified condition is true and then returns the remaining values. (Defined by Observable.)
Public Extension Method SkipWhile<T>(Func<T, Int32, Boolean>) Overloaded. Bypasses values in an observable sequence as long as a specified condition is true and then returns the remaining values. (Defined by Observable.)
Public Extension Method StartWith<T>T[]) Overloaded. Prepends a sequence of values to an observable sequence with the specified source and values. (Defined by Observable.)
Public Extension Method StartWith<T>(IScheduler, T[]) Overloaded. Prepends a sequence of values to an observable sequence with the specified source, scheduler and values. (Defined by Observable.)
Public Extension Method Subscribe<T>() Overloaded. Evaluates the observable sequence with a specified source. (Defined by ObservableExtensions.)
Public Extension Method Subscribe<T>(Action<T>) Overloaded. Subscribes an element handler to an observable sequence. (Defined by ObservableExtensions.)
Public Extension Method Subscribe<T>(Action<T>, Action<Exception>) Overloaded. Subscribes an element handler and an exception handler to an observable sequence. (Defined by ObservableExtensions.)
Public Extension Method Subscribe<T>(Action<T>, Action) Overloaded. Subscribes an element handler and a completion handler to an observable sequence. (Defined by ObservableExtensions.)
Public Extension Method Subscribe<T>(Action<T>, Action<Exception>, Action) Overloaded. Subscribes an element handler, an exception handler, and a completion handler to an observable sequence. (Defined by ObservableExtensions.)
Public Extension Method SubscribeOn<T>(SynchronizationContext) Overloaded. Asynchronously subscribes and unsubscribes observers on the specified synchronization context. (Defined by Observable.)
Public Extension Method SubscribeOn<T>(Control) Overloaded. (Defined by ControlObservable.)
Public Extension Method SubscribeOn<T>(Dispatcher) Overloaded. (Defined by DispatcherObservable.)
Public Extension Method SubscribeOn<T>(DispatcherScheduler) Overloaded. (Defined by DispatcherObservable.)
Public Extension Method SubscribeOn<T>(IScheduler) Overloaded. Asynchronously subscribes and unsubscribes observers on the specified scheduler. (Defined by Observable.)
Public Extension Method SubscribeOnDispatcher<T> (Defined by DispatcherObservable.)
Public Extension Method Synchronize<T>() Overloaded. Synchronizes the observable sequence. (Defined by Observable.)
Public Extension Method Synchronize<T>(Object) Overloaded. Synchronizes the observable sequence. (Defined by Observable.)
Public Extension Method Take<T> Returns a specified number of contiguous values from the start of an observable sequence. (Defined by Observable.)
Public Extension Method TakeLast<T> Returns a specified number of contiguous elements from the end of an observable sequence. (Defined by Observable.)
Public Extension Method TakeUntil<T, TOther> Returns the values from the source observable sequence until the other observable sequence produces a value. (Defined by Observable.)
Public Extension Method TakeWhile<T>(Func<T, Boolean>) Overloaded. Returns values from an observable sequence as long as a specified condition is true, and then skips the remaining values. (Defined by Observable.)
Public Extension Method TakeWhile<T>(Func<T, Int32, Boolean>) Overloaded. Returns values from an observable sequence as long as a specified condition is true, and then skips the remaining values. (Defined by Observable.)
Public Extension Method Then<T, TResult> Matches when the observable sequence has an available value and projects the value. (Defined by Observable.)
Public Extension Method Throttle<T>(TimeSpan) Overloaded. Ignores the values from an observable sequence which are followed by another value before due time with the specified source and dueTime. (Defined by Observable.)
Public Extension Method Throttle<T>(TimeSpan, IScheduler) Overloaded. Ignores the values from an observable sequence which are followed by another value before due time with the specified source, dueTime and scheduler. (Defined by Observable.)
Public Extension Method TimeInterval<T>() Overloaded. Records the time interval between consecutive values in an observable sequence with the specified source. (Defined by Observable.)
Public Extension Method TimeInterval<T>(IScheduler) Overloaded. Records the time interval between consecutive values in an observable sequence with the specified source and scheduler. (Defined by Observable.)
Public Extension Method Timeout<T>(TimeSpan) Overloaded. Returns either the observable sequence or an TimeoutException if dueTime elapses. (Defined by Observable.)
Public Extension Method Timeout<T>(DateTimeOffset) Overloaded. Returns either the observable sequence or a TimeoutException if dueTime elapses. (Defined by Observable.)
Public Extension Method Timeout<T>(TimeSpan, IObservable<T>) Overloaded. Returns the source observable sequence or the other observable sequence if dueTime elapses. (Defined by Observable.)
Public Extension Method Timeout<T>(DateTimeOffset, IObservable<T>) Overloaded. Returns either the observable sequence or an TimeoutException if dueTime elapses. (Defined by Observable.)
Public Extension Method Timeout<T>(TimeSpan, IScheduler) Overloaded. Returns either the observable sequence or an TimeoutException if dueTime elapses. (Defined by Observable.)
Public Extension Method Timeout<T>(DateTimeOffset, IScheduler) Overloaded. Returns either the observable sequence or an TimeoutException if dueTime elapses. (Defined by Observable.)
Public Extension Method Timeout<T>(TimeSpan, IObservable<T>, IScheduler) Overloaded. Returns the source observable sequence or the other observable sequence if dueTime elapses. (Defined by Observable.)
Public Extension Method Timeout<T>(DateTimeOffset, IObservable<T>, IScheduler) Overloaded. Returns the source observable sequence or the other observable sequence if dueTime elapses. (Defined by Observable.)
Public Extension Method Timestamp<T>() Overloaded. Records the timestamp for each value in an observable sequence with the specified source. (Defined by Observable.)
Public Extension Method Timestamp<T>(IScheduler) Overloaded. Records the timestamp for each value in an observable sequence with the specified source and scheduler. (Defined by Observable.)
Public Extension Method ToArray<T> Creates an array from an observable sequence. (Defined by Observable.)
Public Extension Method ToDictionary<T, TKey>(Func<T, TKey>) Overloaded. Creates a dictionary from an observable sequence according to a specified key selector function. (Defined by Observable.)
Public Extension Method ToDictionary<T, TKey>(Func<T, TKey>, IEqualityComparer<TKey>) Overloaded. Creates a dictionary from an observable sequence according to a specified key selector function, and a comparer. (Defined by Observable.)
Public Extension Method ToDictionary<T, TKey, TElement>(Func<T, TKey>, Func<T, TElement>) Overloaded. Creates a dictionary from an observable sequence according to a specified key selector function, and an element selector function. (Defined by Observable.)
Public Extension Method ToDictionary<T, TKey, TElement>(Func<T, TKey>, Func<T, TElement>, IEqualityComparer<TKey>) Overloaded. Creates a dictionary from an observable sequence according to a specified key selector function, a comparer, and an element selector function. (Defined by Observable.)
Public Extension Method ToEnumerable<T> Converts an observable sequence to an enumerable sequence. (Defined by Observable.)
Public Extension Method ToEvent<T> Exposes an observable sequence as an object with a .NET event with a specified source. (Defined by Observable.)
Public Extension Method ToList<T> Creates a list from an observable sequence. (Defined by Observable.)
Public Extension Method ToLookup<T, TKey>(Func<T, TKey>) Overloaded. Creates a lookup from an observable sequence according to a specified key selector function. (Defined by Observable.)
Public Extension Method ToLookup<T, TKey>(Func<T, TKey>, IEqualityComparer<TKey>) Overloaded. Creates a lookup from an observable sequence according to a specified key selector function, and a comparer. (Defined by Observable.)
Public Extension Method ToLookup<T, TKey, TElement>(Func<T, TKey>, Func<T, TElement>) Overloaded. Creates a lookup from an observable sequence according to a specified key selector function, and an element selector function. (Defined by Observable.)
Public Extension Method ToLookup<T, TKey, TElement>(Func<T, TKey>, Func<T, TElement>, IEqualityComparer<TKey>) Overloaded. Creates a lookup from an observable sequence according to a specified key selector function, a comparer, and an element selector function. (Defined by Observable.)
Public Extension Method ToNotifier<T> Creates a notification callback from an observer. (Defined by Observer.)
Public Extension Method ToTask<T>() Overloaded. Returns a task that contains the last value of the observable sequence. (Defined by TaskObservableExtensions.)
Public Extension Method ToTask<T>(Object) Overloaded. Returns a task that contains the last value of the observable sequence. (Defined by TaskObservableExtensions.)
Public Extension Method ToTask<T>(CancellationToken) Overloaded. Returns a task that contains the last value of the observable sequence. (Defined by TaskObservableExtensions.)
Public Extension Method ToTask<T>(CancellationToken, Object) Overloaded. Returns a task that contains the last value of the observable sequence. (Defined by TaskObservableExtensions.)
Public Extension Method Where<T>(Func<T, Boolean>) Overloaded. Filters the elements of an observable sequence based on a predicate. (Defined by Observable.)
Public Extension Method Where<T>(Func<T, Int32, Boolean>) Overloaded. Filters the elements of an observable sequence based on a predicate by incorporating the element's index. (Defined by Observable.)
Public Extension Method Window<T>(Int32) Overloaded. Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on element count information. (Defined by Observable.)
Public Extension Method Window<T>(TimeSpan) Overloaded. Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on timing information. (Defined by Observable.)
Public Extension Method Window<T>(Int32, Int32) Overloaded. Projects each element of an observable sequence into zero or more windows which are produced based on element count information. (Defined by Observable.)
Public Extension Method Window<T>(TimeSpan, IScheduler) Overloaded. Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on timing information. (Defined by Observable.)
Public Extension Method Window<T>(TimeSpan, TimeSpan) Overloaded. Projects each element of an observable sequence into zero or more windows which are produced based on timing information. (Defined by Observable.)
Public Extension Method Window<T>(TimeSpan, Int32) Overloaded. Projects each element of an observable sequence into a window that is completed when either it’s full or a given amount of time has elapsed. (Defined by Observable.)
Public Extension Method Window<T>(TimeSpan, TimeSpan, IScheduler) Overloaded. Projects each element of an observable sequence into zero or more windows which are produced based on timing information. (Defined by Observable.)
Public Extension Method Window<T>(TimeSpan, Int32, IScheduler) Overloaded. Projects each element of an observable sequence into a window that is completed when either it’s full or a given amount of time has elapsed. (Defined by Observable.)
Public Extension Method Window<T, TWindowClosing>(Func<IObservable<TWindowClosing>>) Overloaded. Projects each element of an observable sequence into consecutive non-overlapping windows. (Defined by Observable.)
Public Extension Method Window<T, TWindowOpening, TWindowClosing>(IObservable<TWindowOpening>, Func<TWindowOpening, IObservable<TWindowClosing>>) Overloaded. Projects each element of an observable sequence into zero or more windows. (Defined by Observable.)
Public Extension Method Zip<T, TSecond, TResult>(IObservable<TSecond>, Func<T, TSecond, TResult>) Overloaded. Merges two observable sequences into one observable sequence by combining their elements in a pairwise fashion. (Defined by Observable.)
Public Extension Method Zip<T, TSecond, TResult>(IEnumerable<TSecond>, Func<T, TSecond, TResult>) Overloaded. Merges an observable sequence and an enumerable sequence into one observable sequence by using the selector function. (Defined by Observable.)

Top

Remarks

A subject acts similar to a proxy in that it acts as both a subscriber and a publisher. Its IObserver interface can be used to subscribe to multiple observable sequences of data. The data is then published through the subject's IObservable interface.

A ReplaySubject buffers items it receives. So a subscription created at a later time can access items from the buffered sequence even if they have already been published. How many items a ReplaySubject will buffer depends on the parameters passed to the constructor.

Regular subjects do synchronize outgoing calls to subcribed observers using a scheduler.

Examples

In this example we have created a NewsHeadlineFeed class which is just a mock news feed in the form of an observable sequence of strings. It uses the Generate operator to continuoously generate a random news headline within three seconds.

A ReplaySubject is created to subscribe to two news feeds of the NewsHeadlineFeed class. Before the subject is subscribed to the feeds, the Timestamp operator is used to timestamp each headline. So the sequence that the ReplaySubject actually subscribes to is of the type IObservable<Timestamped<string>>. With the headline sequence timestamped, subscribers can subscribe to the subject's observable interface to observe the data stream(s) or a subset of the stream(s) based on the timestamp.

A ReplaySubject buffers items it receives. So a subscription created at a later time can access items from the sequence which have already been buffered and published. A subscriptions is created to the ReplaySubject that receives only local news headlines which occurred 10 seconds before the local news subscription was created. So we basically have the ReplaySubject "replay" what happened 10 seconds earlier.

A local news headline just contains the newsLocation substring ("in your area.").

using System;
using System.Reactive;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Reactive.Concurrency;
using System.Threading;

namespace Example
{
  class Program
  {
    static void Main()
    {
      //*****************************************************************************************************//
      //*** A subject acts similar to a proxy in that it acts as both a subscriber and a publisher        ***//
      //*** It's IObserver interface can be used to subscribe to multiple streams or sequences of data.   ***//
      //*** The data is then published through it's IObservable interface.                                ***//
      //***                                                                                               ***//
      //*** In this example a simple ReplaySubject is used to subscribe to multiple news feeds            ***//
      //*** that provide random news headlines. Before the subject is subscribed to the feeds, we use     ***//
      //*** Timestamp operator to timestamp each headline. Subscribers can then subscribe to the subject  ***//
      //*** observable interface to observe the data stream(s) or a subset of the stream(s) based on      ***//
      //*** time.                                                                                         ***//
      //***                                                                                               ***//
      //*** A ReplaySubject buffers items it receives. So a subscription created at a later time can      ***//
      //*** access items from the sequence which have already been published.                             ***//
      //***                                                                                               ***//
      //*** A subscriptions is created to the ReplaySubject that receives only local news headlines which ***//
      //*** occurred 10 seconds before the local news subscription was created. So we basically have the  ***//
      //*** ReplaySubject "replay" what happened 10 seconds earlier.                                      ***//
      //***                                                                                               ***//
      //*** A local news headline just contains the newsLocation substring ("in your area.").             ***//
      //***                                                                                               ***//
      //*****************************************************************************************************//

      ReplaySubject<Timestamped<string>> myReplaySubject = new ReplaySubject<Timestamped<String>>();


      //*****************************************************************//
      //*** Create news feed #1 and subscribe the ReplaySubject to it ***//
      //*****************************************************************//

      NewsHeadlineFeed NewsFeed1 = new NewsHeadlineFeed("Headline News Feed #1");
      NewsFeed1.HeadlineFeed.Timestamp().Subscribe(myReplaySubject);


      //*****************************************************************//
      //*** Create news feed #2 and subscribe the ReplaySubject to it ***//
      //*****************************************************************//

      NewsHeadlineFeed NewsFeed2 = new NewsHeadlineFeed("Headline News Feed #2");
      NewsFeed2.HeadlineFeed.Timestamp().Subscribe(myReplaySubject);


      //*****************************************************************************************************//
      //*** Create a subscription to the subject's observable sequence. This subscription will filter for ***//
      //*** only local headlines that occurred 10 seconds before the subscription was created.            ***//
      //***                                                                                               ***//
      //*** Since we are using a ReplaySubject with timestamped headlines, we can subscribe to the        ***//
      //*** headlines already past. The ReplaySubject will "replay" them for the localNewSubscription     ***//
      //*** from its buffered sequence of headlines.                                                      ***//
      //*****************************************************************************************************//

      Console.WriteLine("Waiting for 10 seconds before subscribing to local news headline feed.\n");
      Thread.Sleep(10000);

      Console.WriteLine("\n*** Creating local news headline subscription at {0} ***\n", DateTime.Now.ToString());
      Console.WriteLine("This subscription asks the ReplaySubject for the buffered headlines that\n" +
                        "occurred within the last 10 seconds.\n\nPress ENTER to exit.", DateTime.Now.ToString());

      DateTime lastestHeadlineTime = DateTime.Now;
      DateTime earliestHeadlineTime = lastestHeadlineTime - TimeSpan.FromSeconds(10);     
      
      IDisposable localNewsSubscription = myReplaySubject.Where(x => x.Value.Contains("in your area.") &&
                                                               (x.Timestamp >= earliestHeadlineTime) &&
                                                               (x.Timestamp < lastestHeadlineTime)).Subscribe(x =>
      {
        Console.WriteLine("\n************************************\n" +
                          "***[ Local news headline report ]***\n" +
                          "************************************\n" + 
                          "Time         : {0}\n{1}\n\n", x.Timestamp.ToString(), x.Value);
      });

      Console.ReadLine();


      //*******************************//
      //*** Cancel the subscription ***//
      //*******************************//

      localNewsSubscription.Dispose();
      

      //*************************************************************************//
      //*** Unsubscribe all the ReplaySubject's observers and free resources. ***//
      //*************************************************************************//

      myReplaySubject.Dispose();    
    }
  }



  //*********************************************************************************//
  //***                                                                           ***//
  //*** The NewsHeadlineFeed class is just a mock news feed in the form of an     ***//
  //*** observable sequence in Reactive Extensions.                               ***//
  //***                                                                           ***//
  //*********************************************************************************//
  class NewsHeadlineFeed
  {
    private string feedName;                     // Feedname used to label the stream
    private IObservable<string> headlineFeed;    // The actual data stream
    private readonly Random rand = new Random(); // Used to stream random headlines.


    //*** A list of predefined news events to combine with a simple location string ***//
    static readonly string[] newsEvents = { "A tornado occurred ",
                                            "Weather watch for snow storm issued ",
                                            "A robbery occurred ",
                                            "We have a lottery winner ",
                                            "An earthquake occurred ",
                                            "Severe automobile accident "};

    //*** A list of predefined location strings to combine with a news event. ***//
    static readonly string[] newsLocations = { "in your area.",
                                               "in Dallas, Texas.",
                                               "somewhere in Iraq.",
                                               "Lincolnton, North Carolina",
                                               "Redmond, Washington"};

    public IObservable<string> HeadlineFeed
    {
      get { return headlineFeed; }
    }

    public NewsHeadlineFeed(string name)
    {
      feedName = name;

      //*****************************************************************************************//
      //*** Using the Generate operator to generate a continous stream of headline that occur ***//
      //*** randomly within 5 seconds.                                                        ***//
      //*****************************************************************************************//
      headlineFeed = Observable.Generate(RandNewsEvent(),
                                         evt => true,
                                         evt => RandNewsEvent(),
                                         evt => { Thread.Sleep(rand.Next(3000)); return evt; },
                                         Scheduler.ThreadPool);
    }


    //****************************************************************//
    //*** Some very simple formatting of the headline event string ***//
    //****************************************************************//
    private string RandNewsEvent()
    {
      return "Feedname     : " + feedName + "\nHeadline     : " + newsEvents[rand.Next(newsEvents.Length)] +
             newsLocations[rand.Next(newsLocations.Length)];
    }
  }
}

The following output was generated with the example code. The new feeds are random so it is possible that you may have to run it more than once to see a local news headline.

Waiting for 10 seconds before subscribing to local news headline feed.

** Creating local news headline subscription at 5/9/2011 4:07:48 AM **

This subscription asks the ReplaySubject for the buffered headlines that
occurred within the last 10 seconds.

Press ENTER to exit.

********************************** [ Local news headline report ] ********************************** Time : 5/9/2011 4:07:42 AM -04:00 Feedname : Headline News Feed #2 Headline : We have a lottery winner in your area.

********************************** [ Local news headline report ] ********************************** Time : 5/9/2011 4:07:47 AM -04:00 Feedname : Headline News Feed #1 Headline : Weather watch for snow storm issued in your area.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

System.Reactive.Subjects Namespace