ISubject<TSource, TResult> Interface

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

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

Syntax

'Declaration
Public Interface ISubject(Of In TSource, Out TResult) _
    Inherits IObserver(Of TSource), IObservable(Of TResult)
'Usage
Dim instance As ISubject(Of In TSource, Out TResult)
public interface ISubject<in TSource, out TResult> : IObserver<TSource>, 
    IObservable<TResult>
generic<typename TSource, typename TResult>
public interface class ISubject : IObserver<TSource>, 
    IObservable<TResult>
type ISubject<'TSource, 'TResult> =  
    interface
        interface IObserver<'TSource>
        interface IObservable<'TResult>
    end
JScript does not support generic types and methods.

Type Parameters

  • inTSource
    The type of source.

    This type parameter is contravariant. That is, you can use either the type you specified or any type that is less derived. For more information about covariance and contravariance, see .

  • outTResult
    The type of result.

    This type parameter is covariant. That is, you can use either the type you specified or any type that is more derived. For more information about covariance and contravariance, see .

The ISubject<TSource, TResult> type exposes the following members.

Methods

  Name Description
Public method OnCompleted (Inherited from IObserver<TSource>.)
Public method OnError (Inherited from IObserver<TSource>.)
Public method OnNext (Inherited from IObserver<TSource>.)
Public method Subscribe (Inherited from IObservable<TResult>.)

Top

Extension Methods

  Name Description
Public Extension Method Aggregate<TResult>(Func<TResult, TResult, TResult>) Overloaded. Applies an accumulator function over an observable sequence. (Defined by Observable.)
Public Extension Method Aggregate<TResult, TAccumulate>(TAccumulate, Func<TAccumulate, TResult, TAccumulate>) Overloaded. Applies an accumulator function over an observable sequence with the specified seed value. (Defined by Observable.)
Public Extension Method All<TResult> Determines whether all elements of an observable sequence satisfies a condition. (Defined by Observable.)
Public Extension Method Amb<TResult> Propagates the observable sequence that reacts first with the specified first and second sequence. (Defined by Observable.)
Public Extension Method And<TResult, TRight> Matches when both observable sequences have an available value. (Defined by Observable.)
Public Extension Method Any<TResult>() Overloaded. Determines whether an observable sequence contains any elements. (Defined by Observable.)
Public Extension Method Any<TResult>(Func<TResult, Boolean>) Overloaded. Determines whether all elements of an observable sequence satisfies a condition. (Defined by Observable.)
Public Extension Method AsObservable<TResult> Hides the identity of an observable sequence. (Defined by Observable.)
Public Extension Method AsObserver<TSource> Hides the identity of an observer. (Defined by Observer.)
Public Extension Method AsQbservable<TResult> Converts an observable sequence into a queryable observable sequence. (Defined by Qbservable.)
Public Extension Method AssertEqual<TResult> (Defined by Extensions.)
Public Extension Method Buffer<TResult>(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<TResult>(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<TResult>(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<TResult>(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<TResult>(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<TResult>(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<TResult>(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<TResult>(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<TResult, TBufferClosing>(Func<IObservable<TBufferClosing>>) Overloaded. Indicates each element of an observable sequence into consecutive non-overlapping buffers. (Defined by Observable.)
Public Extension Method Buffer<TResult, 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<TResult>(IObservable<TResult>) Overloaded. Continues an observable sequence that is terminated by an exception with the next observable sequence. (Defined by Observable.)
Public Extension Method Catch<TResult, TException>(Func<TException, IObservable<TResult>>) 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<TResult, 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<TResult> Concatenates two observable sequences. (Defined by Observable.)
Public Extension Method Contains<TResult>(TResult) Overloaded. Determines whether an observable sequence contains a specified element by using the default equality comparer. (Defined by Observable.)
Public Extension Method Contains<TResult>(TResult, IEqualityComparer<TResult>) 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<TResult> Returns a Int32 that represents the total number of elements in an observable sequence. (Defined by Observable.)
Public Extension Method DefaultIfEmpty<TResult>() 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<TResult>(TResult) 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<TResult>(TimeSpan) Overloaded. Indicates the observable sequence by due time with the specified source and dueTime. (Defined by Observable.)
Public Extension Method Delay<TResult>(DateTimeOffset) Overloaded. Indicates the observable sequence by due time with the specified source and dueTime. (Defined by Observable.)
Public Extension Method Delay<TResult>(TimeSpan, IScheduler) Overloaded. Indicates the observable sequence by due time with the specified source, dueTime and scheduler. (Defined by Observable.)
Public Extension Method Delay<TResult>(DateTimeOffset, IScheduler) Overloaded. Indicates the observable sequence by due time with the specified source, dueTime and scheduler. (Defined by Observable.)
Public Extension Method Distinct<TResult>() Overloaded. Returns an observable sequence that contains only distinct elements with a specified source. (Defined by Observable.)
Public Extension Method Distinct<TResult>(IEqualityComparer<TResult>) Overloaded. Returns an observable sequence that contains only distinct elements according to the comparer. (Defined by Observable.)
Public Extension Method Distinct<TResult, TKey>(Func<TResult, TKey>) Overloaded. Returns an observable sequence that contains only distinct elements according to the keySelector. (Defined by Observable.)
Public Extension Method Distinct<TResult, TKey>(Func<TResult, TKey>, IEqualityComparer<TKey>) Overloaded. Returns an observable sequence that contains only distinct elements according to the keySelector. (Defined by Observable.)
Public Extension Method DistinctUntilChanged<TResult>() Overloaded. Returns an observable sequence that contains only distinct contiguous elements with a specified source. (Defined by Observable.)
Public Extension Method DistinctUntilChanged<TResult>(IEqualityComparer<TResult>) Overloaded. Returns an observable sequence that contains only distinct contiguous elements according to the comparer. (Defined by Observable.)
Public Extension Method DistinctUntilChanged<TResult, TKey>(Func<TResult, TKey>) Overloaded. Returns an observable sequence that contains only distinct contiguous elements according to the keySelector. (Defined by Observable.)
Public Extension Method DistinctUntilChanged<TResult, TKey>(Func<TResult, 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<TResult>(Action<TResult>) Overloaded. Invokes an action for each element in the observable sequence. (Defined by Observable.)
Public Extension Method Do<TResult>(IObserver<TResult>) 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<TResult>(Action<TResult>, 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<TResult>(Action<TResult>, 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<TResult>(Action<TResult>, 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<TResult> Returns the element at a specified index in a sequence. (Defined by Observable.)
Public Extension Method ElementAtOrDefault<TResult> 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<TResult> Invokes a specified action after source observable sequence terminates normally or by an exception. (Defined by Observable.)
Public Extension Method First<TResult>() Overloaded. Returns the first element of an observable sequence with a specified source. (Defined by Observable.)
Public Extension Method First<TResult>(Func<TResult, Boolean>) Overloaded. Returns the first element of an observable sequence that matches the predicate. (Defined by Observable.)
Public Extension Method FirstOrDefault<TResult>() 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<TResult>(Func<TResult, 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<TResult, R> (Defined by MyExt.)
Public Extension Method ForEach<TResult> Invokes an action for each element in the observable sequence, and blocks until the sequence is terminated. (Defined by Observable.)
Public Extension Method GetEnumerator<TResult> Returns an enumerator that enumerates all values of the observable sequence. (Defined by Observable.)
Public Extension Method GroupBy<TResult, TKey>(Func<TResult, TKey>) Overloaded. Groups the elements of an observable sequence according to a specified key selector function. (Defined by Observable.)
Public Extension Method GroupBy<TResult, TKey>(Func<TResult, 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<TResult, TKey, TElement>(Func<TResult, TKey>, Func<TResult, 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<TResult, TKey, TElement>(Func<TResult, TKey>, Func<TResult, 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<TResult, TKey, TDuration>(Func<TResult, TKey>, Func<IGroupedObservable<TKey, TResult>, IObservable<TDuration>>) Overloaded. Groups the elements of an observable sequence according to a specified key selector function. (Defined by Observable.)
Public Extension Method GroupByUntil<TResult, TKey, TDuration>(Func<TResult, TKey>, Func<IGroupedObservable<TKey, TResult>, 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<TResult, TKey, TElement, TDuration>(Func<TResult, TKey>, Func<TResult, 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<TResult, TKey, TElement, TDuration>(Func<TResult, TKey>, Func<TResult, 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<TResult, 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<TResult> Ignores all values in an observable sequence leaving only the termination messages. (Defined by Observable.)
Public Extension Method Join<TResult, TRight, TLeftDuration, TRightDuration, TResult> Correlates the elements of two sequences based on overlapping durations. (Defined by Observable.)
Public Extension Method Last<TResult>() Overloaded. Returns the last element of an observable sequence with a specified source. (Defined by Observable.)
Public Extension Method Last<TResult>(Func<TResult, Boolean>) Overloaded. Returns the last element of an observable sequence that matches the predicate. (Defined by Observable.)
Public Extension Method LastOrDefault<TResult>() Overloaded. Returns last element in the observable sequence, or a default value if no value is found. (Defined by Observable.)
Public Extension Method LastOrDefault<TResult>(Func<TResult, 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<TResult> Samples the most recent value in an observable sequence. (Defined by Observable.)
Public Extension Method LongCount<TResult> Returns a Int64 that represents the total number of elements in an observable sequence. (Defined by Observable.)
Public Extension Method Materialize<TResult> Materializes the implicit notifications of an observable sequence as explicit notification values. (Defined by Observable.)
Public Extension Method Max<TResult>() Overloaded. Returns the maximum element in an observable sequence. (Defined by Observable.)
Public Extension Method Max<TResult>(IComparer<TResult>) Overloaded. Returns the maximum value in an observable sequence according to the specified comparer. (Defined by Observable.)
Public Extension Method MaxBy<TResult, TKey>(Func<TResult, TKey>) Overloaded. Returns the elements in an observable sequence with the maximum key value. (Defined by Observable.)
Public Extension Method MaxBy<TResult, TKey>(Func<TResult, TKey>, IComparer<TKey>) Overloaded. Returns the elements in an observable sequence with the maximum key value. (Defined by Observable.)
Public Extension Method Merge<TResult>(IObservable<TResult>) Overloaded. Merges an observable sequence of observable sequences into an observable sequence. (Defined by Observable.)
Public Extension Method Merge<TResult>(IObservable<TResult>, IScheduler) Overloaded. Merges two observable sequences into a single observable sequence. (Defined by Observable.)
Public Extension Method Min<TResult>() Overloaded. Returns the minimum element in an observable sequence. (Defined by Observable.)
Public Extension Method Min<TResult>(IComparer<TResult>) Overloaded. Returns the minimum value in an observable sequence according to the specified comparer. (Defined by Observable.)
Public Extension Method MinBy<TResult, TKey>(Func<TResult, TKey>) Overloaded. Returns the elements in an observable sequence with the minimum key value. (Defined by Observable.)
Public Extension Method MinBy<TResult, TKey>(Func<TResult, 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<TResult> Samples the most recent value in an observable sequence. (Defined by Observable.)
Public Extension Method Multicast<TResult, TResult>(ISubject<TResult, 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<TResult, TIntermediate, TResult>(Func<ISubject<TResult, 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<TResult> Samples the next value (blocking without buffering) from in an observable sequence. (Defined by Observable.)
Public Extension Method ObserveOn<TResult>(SynchronizationContext) Overloaded. Asynchronously notify observers on the specified synchronization context. (Defined by Observable.)
Public Extension Method ObserveOn<TResult>(Control) Overloaded. (Defined by ControlObservable.)
Public Extension Method ObserveOn<TResult>(Dispatcher) Overloaded. (Defined by DispatcherObservable.)
Public Extension Method ObserveOn<TResult>(DispatcherScheduler) Overloaded. (Defined by DispatcherObservable.)
Public Extension Method ObserveOn<TResult>(IScheduler) Overloaded. Asynchronously notify observers on the specified scheduler. (Defined by Observable.)
Public Extension Method ObserveOnDispatcher<TResult> (Defined by DispatcherObservable.)
Public Extension Method OnErrorResumeNext<TResult> Continues an observable sequence that is terminated normally or by an exception with the next observable sequence. (Defined by Observable.)
Public Extension Method Publish<TResult>() Overloaded. Returns a connectable observable sequence that shares a single subscription to the underlying sequence. (Defined by Observable.)
Public Extension Method Publish<TResult>(TResult) 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<TResult, TResult>(Func<IObservable<TResult>, 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<TResult, TResult>(Func<IObservable<TResult>, IObservable<TResult>>, TResult) 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<TResult>() 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<TResult, TResult>(Func<IObservable<TResult>, 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<TResult>() Overloaded. Repeats the observable sequence indefinitely. (Defined by Observable.)
Public Extension Method Repeat<TResult>(Int32) Overloaded. Repeats the observable sequence indefinitely. (Defined by Observable.)
Public Extension Method Replay<TResult>() 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<TResult>(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<TResult>(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<TResult>(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<TResult>(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<TResult>(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<TResult>(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<TResult>(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<TResult, TResult>(Func<IObservable<TResult>, 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<TResult, TResult>(Func<IObservable<TResult>, 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<TResult, TResult>(Func<IObservable<TResult>, 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<TResult, TResult>(Func<IObservable<TResult>, 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<TResult, TResult>(Func<IObservable<TResult>, 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<TResult, TResult>(Func<IObservable<TResult>, 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<TResult, TResult>(Func<IObservable<TResult>, 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<TResult, TResult>(Func<IObservable<TResult>, 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<TResult>() Overloaded. Repeats the source observable sequence until it successfully terminates. (Defined by Observable.)
Public Extension Method Retry<TResult>(Int32) Overloaded. Repeats the source observable sequence until it successfully terminates. (Defined by Observable.)
Public Extension Method Sample<TResult>(TimeSpan) Overloaded. Samples the observable sequence at each interval. (Defined by Observable.)
Public Extension Method Sample<TResult>(TimeSpan, IScheduler) Overloaded. Samples the observable sequence at each interval with the specified source, interval and scheduler. (Defined by Observable.)
Public Extension Method Sample<TResult, TSample>(IObservable<TSample>) Overloaded. Samples the observable sequence at sampling ticks with the specified source and sampler. (Defined by Observable.)
Public Extension Method Scan<TResult>(Func<TResult, TResult, TResult>) 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<TResult, TAccumulate>(TAccumulate, Func<TAccumulate, TResult, 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<TResult, TResult>(Func<TResult, 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<TResult, TResult>(Func<TResult, 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<TResult, 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<TResult, TResult>(Func<TResult, 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<TResult, TResult>(Func<TResult, 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<TResult, TResult>(Func<TResult, 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<TResult, TCollection, TResult>(Func<TResult, IEnumerable<TCollection>>, Func<TResult, 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<TResult, TCollection, TResult>(Func<TResult, IObservable<TCollection>>, Func<TResult, 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<TResult>(IObservable<TResult>) Overloaded. Determines whether two sequences are equal by comparing the elements pairwise. (Defined by Observable.)
Public Extension Method SequenceEqual<TResult>(IObservable<TResult>, IEqualityComparer<TResult>) Overloaded. Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer. (Defined by Observable.)
Public Extension Method Single<TResult>() 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<TResult>(Func<TResult, 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<TResult>() 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<TResult>(Func<TResult, 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<TResult> Bypasses a specified number of values in an observable sequence and then returns the remaining values. (Defined by Observable.)
Public Extension Method SkipLast<TResult> Bypasses a specified number of elements at the end of an observable sequence. (Defined by Observable.)
Public Extension Method SkipUntil<TResult, 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<TResult>(Func<TResult, 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<TResult>(Func<TResult, 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<TResult>TResult[]) Overloaded. Prepends a sequence of values to an observable sequence with the specified source and values. (Defined by Observable.)
Public Extension Method StartWith<TResult>(IScheduler, TResult[]) Overloaded. Prepends a sequence of values to an observable sequence with the specified source, scheduler and values. (Defined by Observable.)
Public Extension Method Subscribe<TResult>() Overloaded. Evaluates the observable sequence with a specified source. (Defined by ObservableExtensions.)
Public Extension Method Subscribe<TResult>(Action<TResult>) Overloaded. Subscribes an element handler to an observable sequence. (Defined by ObservableExtensions.)
Public Extension Method Subscribe<TResult>(Action<TResult>, Action<Exception>) Overloaded. Subscribes an element handler and an exception handler to an observable sequence. (Defined by ObservableExtensions.)
Public Extension Method Subscribe<TResult>(Action<TResult>, Action) Overloaded. Subscribes an element handler and a completion handler to an observable sequence. (Defined by ObservableExtensions.)
Public Extension Method Subscribe<TResult>(Action<TResult>, 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<TResult>(SynchronizationContext) Overloaded. Asynchronously subscribes and unsubscribes observers on the specified synchronization context. (Defined by Observable.)
Public Extension Method SubscribeOn<TResult>(Control) Overloaded. (Defined by ControlObservable.)
Public Extension Method SubscribeOn<TResult>(Dispatcher) Overloaded. (Defined by DispatcherObservable.)
Public Extension Method SubscribeOn<TResult>(DispatcherScheduler) Overloaded. (Defined by DispatcherObservable.)
Public Extension Method SubscribeOn<TResult>(IScheduler) Overloaded. Asynchronously subscribes and unsubscribes observers on the specified scheduler. (Defined by Observable.)
Public Extension Method SubscribeOnDispatcher<TResult> (Defined by DispatcherObservable.)
Public Extension Method Synchronize<TResult>() Overloaded. Synchronizes the observable sequence. (Defined by Observable.)
Public Extension Method Synchronize<TResult>(Object) Overloaded. Synchronizes the observable sequence. (Defined by Observable.)
Public Extension Method Take<TResult> Returns a specified number of contiguous values from the start of an observable sequence. (Defined by Observable.)
Public Extension Method TakeLast<TResult> Returns a specified number of contiguous elements from the end of an observable sequence. (Defined by Observable.)
Public Extension Method TakeUntil<TResult, TOther> Returns the values from the source observable sequence until the other observable sequence produces a value. (Defined by Observable.)
Public Extension Method TakeWhile<TResult>(Func<TResult, 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<TResult>(Func<TResult, 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<TResult, TResult> Matches when the observable sequence has an available value and projects the value. (Defined by Observable.)
Public Extension Method Throttle<TResult>(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<TResult>(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<TResult>() Overloaded. Records the time interval between consecutive values in an observable sequence with the specified source. (Defined by Observable.)
Public Extension Method TimeInterval<TResult>(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<TResult>(TimeSpan) Overloaded. Returns either the observable sequence or an TimeoutException if dueTime elapses. (Defined by Observable.)
Public Extension Method Timeout<TResult>(DateTimeOffset) Overloaded. Returns either the observable sequence or a TimeoutException if dueTime elapses. (Defined by Observable.)
Public Extension Method Timeout<TResult>(TimeSpan, IObservable<TResult>) Overloaded. Returns the source observable sequence or the other observable sequence if dueTime elapses. (Defined by Observable.)
Public Extension Method Timeout<TResult>(DateTimeOffset, IObservable<TResult>) Overloaded. Returns either the observable sequence or an TimeoutException if dueTime elapses. (Defined by Observable.)
Public Extension Method Timeout<TResult>(TimeSpan, IScheduler) Overloaded. Returns either the observable sequence or an TimeoutException if dueTime elapses. (Defined by Observable.)
Public Extension Method Timeout<TResult>(DateTimeOffset, IScheduler) Overloaded. Returns either the observable sequence or an TimeoutException if dueTime elapses. (Defined by Observable.)
Public Extension Method Timeout<TResult>(TimeSpan, IObservable<TResult>, IScheduler) Overloaded. Returns the source observable sequence or the other observable sequence if dueTime elapses. (Defined by Observable.)
Public Extension Method Timeout<TResult>(DateTimeOffset, IObservable<TResult>, IScheduler) Overloaded. Returns the source observable sequence or the other observable sequence if dueTime elapses. (Defined by Observable.)
Public Extension Method Timestamp<TResult>() Overloaded. Records the timestamp for each value in an observable sequence with the specified source. (Defined by Observable.)
Public Extension Method Timestamp<TResult>(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<TResult> Creates an array from an observable sequence. (Defined by Observable.)
Public Extension Method ToDictionary<TResult, TKey>(Func<TResult, TKey>) Overloaded. Creates a dictionary from an observable sequence according to a specified key selector function. (Defined by Observable.)
Public Extension Method ToDictionary<TResult, TKey>(Func<TResult, 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<TResult, TKey, TElement>(Func<TResult, TKey>, Func<TResult, 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<TResult, TKey, TElement>(Func<TResult, TKey>, Func<TResult, 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<TResult> Converts an observable sequence to an enumerable sequence. (Defined by Observable.)
Public Extension Method ToEvent<TResult> Exposes an observable sequence as an object with a .NET event with a specified source. (Defined by Observable.)
Public Extension Method ToList<TResult> Creates a list from an observable sequence. (Defined by Observable.)
Public Extension Method ToLookup<TResult, TKey>(Func<TResult, TKey>) Overloaded. Creates a lookup from an observable sequence according to a specified key selector function. (Defined by Observable.)
Public Extension Method ToLookup<TResult, TKey>(Func<TResult, 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<TResult, TKey, TElement>(Func<TResult, TKey>, Func<TResult, 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<TResult, TKey, TElement>(Func<TResult, TKey>, Func<TResult, 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<TSource> Creates a notification callback from an observer. (Defined by Observer.)
Public Extension Method ToTask<TResult>() Overloaded. Returns a task that contains the last value of the observable sequence. (Defined by TaskObservableExtensions.)
Public Extension Method ToTask<TResult>(Object) Overloaded. Returns a task that contains the last value of the observable sequence. (Defined by TaskObservableExtensions.)
Public Extension Method ToTask<TResult>(CancellationToken) Overloaded. Returns a task that contains the last value of the observable sequence. (Defined by TaskObservableExtensions.)
Public Extension Method ToTask<TResult>(CancellationToken, Object) Overloaded. Returns a task that contains the last value of the observable sequence. (Defined by TaskObservableExtensions.)
Public Extension Method Where<TResult>(Func<TResult, Boolean>) Overloaded. Filters the elements of an observable sequence based on a predicate. (Defined by Observable.)
Public Extension Method Where<TResult>(Func<TResult, 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<TResult>(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<TResult>(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<TResult>(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<TResult>(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<TResult>(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<TResult>(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<TResult>(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<TResult>(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<TResult, TWindowClosing>(Func<IObservable<TWindowClosing>>) Overloaded. Projects each element of an observable sequence into consecutive non-overlapping windows. (Defined by Observable.)
Public Extension Method Window<TResult, 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<TResult, TSecond, TResult>(IObservable<TSecond>, Func<TResult, 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<TResult, TSecond, TResult>(IEnumerable<TSecond>, Func<TResult, 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

This subject interface provides the flexibility to a subject to observe an observable sequence of one type while publishing an observable sequence of another type.

Examples

This example demonstrates implementing an ISubject<TSource, TResult> which observes an observable sequence of one type while publishing an observable sequence of another type. The AsciiConverterSubject in this example demonstrates the implementation by observing sequences of type char and publishing an observable sequence of int. The published observable sequence of int is the ASCII code for each char value it observes.

using System;
using System.Collections.Generic;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Threading;

namespace Example
{
  class Program
  {
    static void Main()
    {
      //****************************************************************************************//
      //*** Create an observable sequence of char from console input until enter is pressed. ***//
      //****************************************************************************************//
      IObservable<char> keySequence = Observable.Create<char>(observer =>
      {
        bool bContinue = true;

        while (bContinue)
        {
          ConsoleKeyInfo keyInfo = Console.ReadKey(true);

          if (keyInfo.Key != ConsoleKey.Enter)
          {
            observer.OnNext(keyInfo.KeyChar);
          }
          else
          {
            observer.OnCompleted();
            bContinue = false;
          }
        }

        return (() => { });
      });


      //****************************************************************************************//
      //*** Create an AsciiConverterSubject which takes a source type of char and returns an ***//
      //*** observable sequence of int which is the ASCII code for source items of char.     ***//
      //****************************************************************************************//

      AsciiConverterSubject myConverterSubject = new AsciiConverterSubject();


      //****************************************************************************************//
      //*** Subscribe to the keySequence on the .NET threadpool so the main thread can       ***//
      //*** create subscriptions to the AsciiConverterSubject                                ***//
      //****************************************************************************************//

      IDisposable subscription = keySequence.SubscribeOn(Scheduler.ThreadPool).Subscribe(myConverterSubject);


      Console.WriteLine("\nEnter a sequence of keys to have the AsciiConverterSubject\nconvert the keys to their ASCII code values.\n"); 
      Console.WriteLine("Press ENTER to terminate the observable sequence...\n");


      //****************************************************************************************//
      //*** Subscribe to the AsciiConverterSubject and write the ASCII code values to the    ***//
      //*** console window.                                                                  ***//
      //***                                                                                  ***//
      //*** The main thread will wait on the completion of the keySequence. It completes     ***//
      //*** when ENTER is pressed.                                                           ***//
      //****************************************************************************************//

      EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);
      myConverterSubject.Subscribe(c => Console.WriteLine("Ascii Char code {0} entered.",c), () => waitHandle.Set());
      waitHandle.WaitOne();


      //***************************************//
      //*** Explicitly releasing resources. ***//
      //***************************************//
      
      subscription.Dispose();
      myConverterSubject.Dispose();
    }
  }



  //***********************************************************************************************//
  //***                                                                                         ***//
  //*** The AsciiConverterSubject demonstrates an implementation of ISubject<TSource, TResult>. ***//
  //*** It is used to subscribe to an observable sequence of char. It publishes an observable   ***//
  //*** sequence of int which should be the ASCII code for each char value it observes.         ***//
  //***                                                                                         ***//
  //***********************************************************************************************//

  class AsciiConverterSubject : ISubject<char, int>, IDisposable
  {
    private List<IObserver<int>> observerList;
    private bool isDisposed;
    private bool isStopped;
    object gate = new object();
    Exception exception;

    public AsciiConverterSubject()
    {
      observerList = new List<IObserver<int>>();
    }

    public void OnCompleted()
    {
      //****************************************************************************************//
      //*** Make sure the OnCompleted operation is not preempted by another operation        ***//
      //*** which would break the expected behavior.  For example, don't allow an error from ***//
      //*** OnError preempt OnCompleted from anotther thread. Then OnCompleted would follow  ***//
      //*** an error.  That would be an incorrect behavior.                                  ***//
      //****************************************************************************************//

      lock (gate)
      {
        CheckDisposed();

        if (!isStopped)
        {
          foreach (IObserver<int> observer in observerList)
          {
            observer.OnCompleted();
          }

          observerList.Clear();
          isStopped = true;
        }
      }
    }

    public void OnError(Exception error)
    {
      if (error == null)
        throw new ArgumentException("Exception error should not be null.");

      //****************************************************************************************//
      //*** Make sure the OnError operation is not preempted by another operation which      ***//
      //*** would break the expected behavior.  For example, don't allow unsubscribe or an   ***//
      //*** OnCompleted operation to preempt OnError from another thread. This would result  ***//
      //*** in an error following completion.  That would be an incorrect behavior.          ***//
      //****************************************************************************************//

      lock (gate)
      {
        CheckDisposed();

        if (!isStopped)
        {
          exception = error;

          foreach (IObserver<int> observer in observerList)
          {
            observer.OnError(error);
          }

          observerList.Clear();
          isStopped = true;
        }
      }
    }

    public void OnNext(char value)
    {
      //****************************************************************************************//
      //*** Make sure the OnNext operation is not preempted by another operation which       ***//
      //*** would break the expected behavior.  For example, don't allow unsubscribe, errors ***//
      //*** or an OnCompleted operation to preempt OnNext from another thread. This would    ***//
      //*** have the result of items in a sequence following completion, errors, or          ***//
      //*** unsubscribe.  That would be an incorrect behavior.                               ***//
      //****************************************************************************************//

      lock (gate)
      {
        CheckDisposed();

        if (!isStopped)
        {
          foreach (IObserver<int> observer in observerList)
          {
            observer.OnNext(Convert.ToInt32(value));
          }
        }
      }
    }

    public IDisposable Subscribe(IObserver<int> observer)
    {
      if (observer == null)
        throw new ArgumentException("observer should not BehaviorSubject null.");

      //****************************************************************************************//
      //*** Make sure Subscribe occurs in sync with the other operations so we keep the      ***//
      //*** correct behavior depending on whether an error has occurred or the observable    ***//
      //*** sequence has completed.                                                          ***//
      //****************************************************************************************//

      lock (gate)
      {
        CheckDisposed();

        if (!isStopped)
        {
          observerList.Add(observer);
          return new Subscription(observer, this);
        }
        else if (exception != null)
        {
          observer.OnError(exception);
          return Disposable.Empty;
        }
        else
        {
          observer.OnCompleted();
          return Disposable.Empty;
        }
      }
    }

    private void Unsubscribe(IObserver<int> observer)
    {
      //****************************************************************************************//
      //*** Make sure Unsubscribe occurs in sync with the other operations so we keep the    ***//
      //*** correct behavior.                                                                ***//
      //****************************************************************************************//

      lock (gate)
      {
        observerList.Remove(observer);
      }
    }

    public void Dispose()
    {
      //****************************************************************************************//
      //*** Make sure Dispose occurs in sync with the other operations so we keep the        ***//
      //*** correct behavior. For example, Dispose shouldn't preempt the other operations    ***//
      //*** changing state variables after they have been checked.                           ***//
      //****************************************************************************************//

      lock (gate)
      {
        observerList.Clear();
        isStopped = true;
        isDisposed = true;
      }
    }

    private void CheckDisposed()
    {
      if (isDisposed)
        throw new ObjectDisposedException("Subject has been disposed.");
    }


    //************************************************************************************//
    //***                                                                              ***//
    //*** The Subscription class wraps each observer that creates a subscription. This ***//
    //*** is needed to expose an IDisposable interface through which a observer can    ***//
    //*** cancel the subscription.                                                     ***//
    //***                                                                              ***//
    //************************************************************************************//

    class Subscription : IDisposable
    {
      private AsciiConverterSubject subject;
      private IObserver<int> observer;

      public Subscription(IObserver<int> obs, AsciiConverterSubject sub)
      {
        subject = sub;
        observer = obs;
      }

      public void Dispose()
      {
        subject.Unsubscribe(observer);
      }
    }
  }
}

The following output was generated by the example code.

Enter a sequence of keys to have the AsciiConverterSubject
convert the keys to their ASCII code values.

Press ENTER to terminate the observable sequence...

Ascii Char code 59 entered.
Ascii Char code 108 entered.
Ascii Char code 115 entered.
Ascii Char code 100 entered.
Ascii Char code 107 entered.
Ascii Char code 102 entered.
Ascii Char code 59 entered.
Ascii Char code 108 entered.
Ascii Char code 115 entered.
Ascii Char code 100 entered.
Ascii Char code 107 entered.
Ascii Char code 102 entered.
Ascii Char code 59 entered.
Ascii Char code 108 entered.
Ascii Char code 115 entered.
Ascii Char code 107 entered.
Ascii Char code 100 entered.
Ascii Char code 59 entered.
Ascii Char code 102 entered.
Ascii Char code 108 entered.
Ascii Char code 115 entered.
Ascii Char code 107 entered.
Ascii Char code 100 entered.

See Also

Reference

System.Reactive.Subjects Namespace