Skip to content

,System.Action{--0})} ,System.Action{--0},System.Action)} ,System.Action{--0},System.Action{System.Exception})} ,System.Action{--0},System.Action{System.Exception},System.Action)} ,System.IObserver{--0})}

Observable.Do(IObservable, Action) method

Defined in

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

Applies to

netstandard2.0

Overloads

  • 1. public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, Action<TSource> onNext)
  • 2. public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, Action<TSource> onNext, Action onCompleted)
  • 3. public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, Action<TSource> onNext, Action<Exception> onError)
  • 4. public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, Action<TSource> onNext, Action<Exception> onError, Action onCompleted)
  • 5. public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, IObserver<TSource> observer)

1. Overload

public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, Action<TSource> onNext)

Summary: Invokes an action for each element in the observable sequence, and propagates all observer messages through the result sequence. This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableSource sequence.
onNextActionAction to invoke for each element in the observable sequence.

Returns: IObservable -- The source sequence with the side-effecting behavior applied.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or onNext is null.

2. Overload

public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, Action<TSource> onNext, Action onCompleted)

Summary: Invokes an action for each element in the observable sequence and invokes an action upon graceful termination of the observable sequence. This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableSource sequence.
onNextActionAction to invoke for each element in the observable sequence.
onCompletedActionAction to invoke upon graceful termination of the observable sequence.

Returns: IObservable -- The source sequence with the side-effecting behavior applied.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or onNext or onCompleted is null.

3. Overload

public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, Action<TSource> onNext, Action<Exception> onError)

Summary: Invokes an action for each element in the observable sequence and invokes an action upon exceptional termination of the observable sequence. This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableSource sequence.
onNextActionAction to invoke for each element in the observable sequence.
onErrorActionAction to invoke upon exceptional termination of the observable sequence.

Returns: IObservable -- The source sequence with the side-effecting behavior applied.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or onNext or onError is null.

4. Overload

public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, Action<TSource> onNext, Action<Exception> onError, Action onCompleted)

Summary: Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence. This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableSource sequence.
onNextActionAction to invoke for each element in the observable sequence.
onErrorActionAction to invoke upon exceptional termination of the observable sequence.
onCompletedActionAction to invoke upon graceful termination of the observable sequence.

Returns: IObservable -- The source sequence with the side-effecting behavior applied.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or onNext or onError or onCompleted is null.

5. Overload

public static IObservable<TSource> Do<TSource>(this IObservable<TSource> source, IObserver<TSource> observer)

Summary: Invokes the observer's methods for each message in the source sequence. This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.

Type parameters

NameDescription
TSourceThe type of the elements in the source sequence.

Parameters

NameTypeDescription
sourceIObservableSource sequence.
observerIObserverObserver whose methods to invoke as part of the source sequence's observation.

Returns: IObservable -- The source sequence with the side-effecting behavior applied.

Exceptions

TypeCondition
System.ArgumentNullExceptionsource or observer is null.