Skip to content

,System.IObserver{--0})} ,System.IObserver{--0},System.Reactive.Concurrency.IScheduler)}

Observable.Subscribe(IEnumerable, IObserver) method

Defined in

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

Applies to

netstandard2.0

Overloads

  • 1. public static IDisposable Subscribe<TSource>(this IEnumerable<TSource> source, IObserver<TSource> observer)
  • 2. public static IDisposable Subscribe<TSource>(this IEnumerable<TSource> source, IObserver<TSource> observer, IScheduler scheduler)

1. Overload

public static IDisposable Subscribe<TSource>(this IEnumerable<TSource> source, IObserver<TSource> observer)

Summary: Subscribes an observer to an enumerable sequence.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIEnumerableEnumerable sequence to subscribe to.
observerIObserverObserver that will receive notifications from the enumerable sequence.

Returns: IDisposable -- Disposable object that can be used to unsubscribe the observer from the enumerable

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or observer is null.

2. Overload

public static IDisposable Subscribe<TSource>(this IEnumerable<TSource> source, IObserver<TSource> observer, IScheduler scheduler)

Summary: Subscribes an observer to an enumerable sequence, using the specified scheduler to run the enumeration loop.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIEnumerableEnumerable sequence to subscribe to.
observerIObserverObserver that will receive notifications from the enumerable sequence.
scheduler[IScheduler](#Scheduler to perform the enumeration on.

Returns: IDisposable -- Disposable object that can be used to unsubscribe the observer from the enumerable

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or observer or scheduler is null.