0

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?

Jota.Toledo
  • 27,293
  • 11
  • 59
  • 73
  • They are not something to be compared. `pipe` is a method of `RxJS` which you can use lots of operators with it: [https://www.learnrxjs.io/operators](https://www.learnrxjs.io/operators) – Harun Yilmaz Jan 31 '19 at 07:49

2 Answers2

0

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

Web to learn rxjs

Daniel
  • 951
  • 7
  • 20
0
  • RxJs is a library. As per RxJs Documentation-

RxJs is a library for reactive programming using observables that makes it easier to compose asynchronous or callback-based code

  • Pipe is a feature of RxJs. As per Angular Documentation-

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));
Shofol
  • 693
  • 1
  • 11
  • 26