Pipes are filters for transforming data (formats) in the template.
I came across the pipe()
function as below. What does this pipe()
function exactly mean in this case?
return this.http.get<Hero>(url)
.pipe(
tap(_ => this.log(`fetched hero id=${id}`)),
catchError(this.handleError<Hero>(`getHero id=${id}`))
);
Don't get confused with the concepts of Angular and RxJS
We have pipes concept in Angular and pipe()
function in RxJS.
1) Pipes in Angular: A pipe takes in data as input and transforms it to the desired output
https://angular.io/guide/pipes
2) pipe()
function in RxJS: You can use pipes to link operators together. Pipes let you combine multiple functions into a single function.
The pipe()
function takes as its arguments the functions you want to combine, and returns a new function that, when executed, runs the composed functions in sequence.
https://angular.io/guide/rx-library (search for pipes in this URL, you can find the same)
So according to your question, you are referring pipe()
function in RxJS