I'm following the tutorial at https://angular.io, and I'm having trouble finding documentation; specifically for the methods pipe
and tap
. I can't find anything on https://angular.io or http://reactivex.io/rxjs/.
My understanding is that pipe
and tap
are both methods of Observable
, which is being imported from RxJS, correct? What are they supposed to do?
Are these methods part of Angular? What do these two methods do?
Best Solution
You are right, the documentation lacks of those methods. However when I dug into rxjs repository, I found nice comments about tap (too long to paste here) and pipe operators:
In brief:
Pipe: Used to stitch together functional operators into a chain. Before we could just do
observable.filter().map().scan()
, but since every RxJS operator is a standalone function rather than an Observable's method, we needpipe()
to make a chain of those operators (see example above).Tap: Can perform side effects with observed data but does not modify the stream in any way. Formerly called
do()
. You can think of it as if observable was an array over time, thentap()
would be an equivalent toArray.forEach()
.