Shifting to pipeable operators

As we mentioned already, pipeable operators are here, and you can find them by importing the respective operators from the rxjs/operators directory, like so:

import { map } from "rxjs/operators/map";
import { filter } from "rxjs/operators/filter";

To use it, we are now relying on the pipe() operator that we use as the parent operator, if you will. Using the preceding operators will therefore look like this:

import { map } from "rxjs/operators/map";
import { filter } from "rxjs/operators";
import { of } from "rxjs/observable/of";
import { Observable } from "rxjs/Observable";

let stream = of(1,2);
stream.pipe(
map(x => x + 1),
filter(x => x > 1)
)
.subscribe(x => console.log("piped", x)); // emits 2 and 3
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.105.159