How to load Observable rxjs / Rx lib faster in Angularjs2 (2.0.1)

I'm new to Angularjs2 In angular1 I used the promise of a callback function, in angular2 I use

import { Observable } from 'rxjs/Rx';

load Observable lib, the problem is that it loads too many files enter image description here

and that makes my web download too slow. Please help me find a way to do this faster. Thanks

+4
source share
1 answer

Do not import from the main library Rxlike this file requireall other files. Just import what you need from separate files.

import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/observable/of';

Observable.of([1, 2, 3])
  .map(array => { return array.filter(num => num === 2) });

Here we import only the Observablestatic method ofand operator map.

rxjs/add/operator/{operator}, Observable rxjs/add/oservable/{staticMethod}

+5

Source: https://habr.com/ru/post/1657571/


All Articles