简体   繁体   中英

Why do i get too many rxjs file calls in my angular 2 project? (seems to be all of them)

EDIT: i have another project thats also not packaged up, and has calls for observable,subscription,subscriver (and BehaviorSubject). this project however uses those three but not BehaviorSubject.

in the other project it makes 63 rxjs calls, and in this project it makes 340 rxjs calls

I'm asking where to look for what is making those calls (both projects are same in their..settings... both using systemjs,bot run in JIT compilation (for now)

im using Observables, subscription etc in my project, and everytime i import i import them specifically

import { Subscription } from 'rxjs/Subscription';
import { Observable } from 'rxjs/Observable';

also no lines that are like

import "rxjs/Rx"; 

anywhere in the project, but still, when the project starts, it calls for 340 files

在此处输入图片说明

That's because those imports have imports of their own. For instance if you do:

import 'rxjs/add/operator/map';

And look inside map what it imports, and look another level deeper you get:

import { Operator } from '../Operator';
import { Subscriber } from '../Subscriber';
import { Observable } from '../Observable';
import { Observer, PartialObserver } from './Observer';
import { Operator } from './Operator';
import { Subscriber } from './Subscriber';
import { Subscription, AnonymousSubscription, TeardownLogic } from './Subscription';
import { IfObservable } from './observable/IfObservable';
import { ErrorObservable } from './observable/ErrorObservable';

... etc, because some of these imports will import other stuff as well, you get that chain of all the files, but still, this is by far not the entire rxjs library, and with a good package manager (or by using the angular-cli), the final bundle will only contain what's actually necessary for your app

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM