Can someone please explain the difference between rxjs and .pipe?
An example on each would be helpful in understanding both the cases. In what scenario can we use each case?
Can someone please explain the difference between rxjs and .pipe?
An example on each would be helpful in understanding both the cases. In what scenario can we use each case?
Rxjs its a reactive extensions library for javascript official doc
.Pipe its a function of this library example of native js pipe and official rxjs docs
RxJs is a library for reactive programming using observables that makes it easier to compose asynchronous or callback-based code
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.
Pipe in action-
import { filter, map } from 'rxjs/operators';
const squareOdd = of(1, 2, 3, 4, 5)
.pipe(
filter(n => n % 2 !== 0),
map(n => n * n)
);
// Subscribe to get values
squareOdd.subscribe(x => console.log(x));