Skip to content

,System.Int32,System.Action)}

Observable.AutoConnect(IConnectableObservable, int, Action?) method

Defined in

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

Applies to

netstandard2.0

public static IObservable<TSource> AutoConnect<TSource>(this IConnectableObservable<TSource> source, int minObservers = 1, Action<IDisposable>? onConnect = null)

Summary: Automatically connect the upstream IConnectableObservable at most once when the specified number of IObservers have subscribed to this IObservable.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
source[IConnectableObservable](#Connectable observable sequence.
minObservers = 1intThe number of observers required to subscribe before the connection to source happens, non-positive value will trigger an immediate subscription.
onConnect = nullAction?If not null, the connection's IDisposable is provided to it.

Returns: IObservable -- An observable sequence that connects to the source at most once when the given number of observers have subscribed to it.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource is null.