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