Class TapOperator
Extension methods implementing the tap operator.
public static class TapOperator
- Inheritance
-
System.ObjectTapOperator
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
sourceObservable<T>The source sequence to mirror.
onNextAction<T>?An optional side effect invoked with each value before it is forwarded downstream.
onErrorAction<Exception>?An optional side effect invoked with the error before it is forwarded downstream.
onCompleteAction?An optional side effect invoked before completion is forwarded downstream.
Returns
- Observable<T>
An observable that mirrors
sourcewhile running the given side effects.
Type Parameters
TThe 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.