)} ,System.Func{System.IObservable{--0},System.IObservable{--1}})} ,--0)} ,System.Func{System.IObservable{--0},System.IObservable{--1}},--0)}
Observable.Publish(IObservable) method¶
Defined in
Type: Observable
Namespace: System.Reactive.Linq
Assembly: System.Reactive.dll
Applies to
netstandard2.0
Overloads¶
- 1.
public static IConnectableObservable<TSource> Publish<TSource>(this IObservable<TSource> source) - 2.
public static IObservable<TResult> Publish<TSource, TResult>(this IObservable<TSource> source, Func<IObservable<TSource>, IObservable<TResult>> selector) - 3.
public static IConnectableObservable<TSource> Publish<TSource>(this IObservable<TSource> source, TSource initialValue) - 4.
public static IObservable<TResult> Publish<TSource, TResult>(this IObservable<TSource> source, Func<IObservable<TSource>, IObservable<TResult>> selector, TSource initialValue)
1. Overload¶
public static IConnectableObservable<TSource> Publish<TSource>(this IObservable<TSource> source)
Summary: Returns a connectable observable sequence that shares a single subscription to the underlying sequence. This operator is a specialization of Multicast using a regular Subject.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence whose elements will be multicasted through a single shared subscription. |
Returns: IConnectableObservable
Remarks
Subscribers will receive all notifications of the source from the time of the subscription on.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source is null. |
See also
2. Overload¶
public static IObservable<TResult> Publish<TSource, TResult>(this IObservable<TSource> source, Func<IObservable<TSource>, IObservable<TResult>> selector)
Summary: 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. This operator is a specialization of Multicast using a regular Subject.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
TResult | The type of the elements in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence whose elements will be multicasted through a single shared subscription. |
selector | Func | Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all notifications of the source from the time of the subscription on. |
Returns: IObservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or selector is null. |
See also
3. Overload¶
public static IConnectableObservable<TSource> Publish<TSource>(this IObservable<TSource> source, TSource initialValue)
Summary: Returns a connectable observable sequence that shares a single subscription to the underlying sequence and starts with initialValue. This operator is a specialization of Multicast using a BehaviorSubject.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence whose elements will be multicasted through a single shared subscription. |
initialValue | TSource | Initial value received by observers upon subscription. |
Returns: IConnectableObservable
Remarks
Subscribers will receive immediately receive the initial value, followed by all notifications of the source from the time of the subscription on.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source is null. |
See also
4. Overload¶
public static IObservable<TResult> Publish<TSource, TResult>(this IObservable<TSource> source, Func<IObservable<TSource>, IObservable<TResult>> selector, TSource initialValue)
Summary: 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 initialValue. This operator is a specialization of Multicast using a BehaviorSubject.
Type parameters
| Name | Description |
|---|---|
TSource | The type of the elements in the source sequence. |
TResult | The type of the elements in the result sequence. |
Parameters
| Name | Type | Description |
|---|---|---|
source | IObservable | Source sequence whose elements will be multicasted through a single shared subscription. |
selector | Func | Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive immediately receive the initial value, followed by all notifications of the source from the time of the subscription on. |
initialValue | TSource | Initial value received by observers upon subscription. |
Returns: IObservable
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | source or selector is null. |
See also