Tap Operator - RXJS

Tap Operator - RXJS

In this tutorial, we will learn about the Tap Operator of RXJS.

What is Tap Operator?

 The tap Operator is a Utility Operator which is very similar to a helper function,  

Perform a side effect for every emission on the source Observable, but return an Observable that is identical to the source.

tap allows you to perform actions or side effects on an Observable stream without modifying or altering the original stream.

const arr = [1, 2, 3];

const fromArr$ = from(arr);

  .pipe(tap((value) => console.log("Received value: ", value)))
  .subscribe((value) => console.log(`Emitted Values: `, value));

Use of Tap Operator

Change Property Value

Emit Value in Observable

Perform Any Other Action

Instead doing other like unsubsring in map better to do it in tap

Subscribe to our Newsletter

Stay up to date! Get all the latest posts delivered straight to your inbox.

If You Appreciate What We Do Here On TutsCoder, You Should Consider:

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

You might also like

Leave a Comment