is there any difference between import { Observable } from 'rxjs/Observable' and import { Observable } from 'rxjs'?

筅森魡賤 提交于 2019-12-22 04:32:07

问题


When using rxjs in angular 2, is there any difference between import { Observable } from 'rxjs/Observable' and import { Observable } from 'rxjs'?


回答1:


Yes there is a slight difference which is the bundle size. If you aren't using tree shaking library like rollup.js which remove all unnecessary codes, your bundle will be large when importing from 'rxjs' as you are importing everything even if you are using only the Observable. On the other hand if you import from 'rxjs/Observable' you are only importing what you need and the bundle will be smaller.

Import only what you need and patch Observable (this is useful in size-sensitive bundling scenarios)

Ref: https://github.com/ReactiveX/rxjs



来源:https://stackoverflow.com/questions/42084199/is-there-any-difference-between-import-observable-from-rxjs-observable-and

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!