Table of Contents

Class TapOperator

Namespace
RxSharp.Operators
Assembly
RxSharp.dll

Extension methods implementing the tap operator.

public static class TapOperator
Inheritance
System.Object
TapOperator

Methods

Tap<T>(Observable<T>, Action<T>?, Action<Exception>?, Action?)

Mirrors source exactly, invoking the supplied callbacks as side effects for each notification before forwarding that same notification downstream. Any callback left null is simply skipped for that kind of notification.

public static Observable<T> Tap<T>(this Observable<T> source, Action<T>? onNext = null, Action<Exception>? onError = null, Action? onComplete = null)

Parameters

source Observable<T>

The source sequence to mirror.

onNext Action<T>?

An optional side effect invoked with each value before it is forwarded downstream.

onError Action<Exception>?

An optional side effect invoked with the error before it is forwarded downstream.

onComplete Action?

An optional side effect invoked before completion is forwarded downstream.

Returns

Observable<T>

An observable that mirrors source while running the given side effects.

Type Parameters

T

The type of values emitted by source.

Remarks

If a callback throws, the output errors with that exception via OnError instead of forwarding the original notification — for example, if onNext throws, the source value is not forwarded and the thrown exception is emitted as an error instead; if onError throws while handling the source's original error, the new exception is forwarded and the original error is dropped. Unlike rxjs's tap, there are no separate hooks for subscribe/unsubscribe/finalize — only onNext, onError, and onComplete are supported.