Skip to content

,System.Reactive.Subjects.ISubject{--0,--1})} ,System.Func},System.Func{System.IObservable{--1},System.IObservable{--2}})}

Observable.Multicast(IObservable, ISubject) method

Defined in

Type: Observable Namespace: System.Reactive.Linq Assembly: System.Reactive.dll

Applies to

netstandard2.0

Overloads

  • 1. public static IConnectableObservable<TResult> Multicast<TSource, TResult>(this IObservable<TSource> source, ISubject<TSource, TResult> subject)
  • 2. public static IObservable<TResult> Multicast<TSource, TIntermediate, TResult>(this IObservable<TSource> source, Func<ISubject<TSource, TIntermediate>> subjectSelector, Func<IObservable<TIntermediate>, IObservable<TResult>> selector)

1. Overload

public static IConnectableObservable<TResult> Multicast<TSource, TResult>(this IObservable<TSource> source, ISubject<TSource, TResult> subject)

Summary: Multicasts the source sequence notifications through the specified subject to the resulting connectable observable. Upon connection of the connectable observable, the subject is subscribed to the source exactly one, and messages are forwarded to the observers registered with the connectable observable. For specializations with fixed subject types, see Publish, PublishLast, and Replay.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TResultThe type of the elements in the result sequence.

Parameters

NameTypeDescription
sourceIObservableSource sequence whose elements will be pushed into the specified subject.
subject[ISubject](#Subject to push source elements into.

Returns: IConnectableObservable -- A connectable observable sequence that upon connection causes the source sequence to push results into the specified subject.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or subject is null.

2. Overload

public static IObservable<TResult> Multicast<TSource, TIntermediate, TResult>(this IObservable<TSource> source, Func<ISubject<TSource, TIntermediate>> subjectSelector, Func<IObservable<TIntermediate>, IObservable<TResult>> selector)

Summary: Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.
TIntermediateThe type of the elements produced by the intermediate subject.
TResultThe type of the elements in the result sequence.

Parameters

NameTypeDescription
sourceIObservableSource sequence which will be multicasted in the specified selector function.
subjectSelectorFunc>Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function.
selectorFunc, IObservable>Selector function which can use the multicasted source sequence subject to the policies enforced by the created subject.

Returns: IObservable -- An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or subjectSelector or selector is null.