Observable.of is not a function

后端 未结 19 707
旧时难觅i
旧时难觅i 2020-11-30 19:41

I am having issue with importing Observable.of function in my project. My Intellij sees everything. In my code I have:

import {Observable} from          


        
19条回答
  •  庸人自扰
    2020-11-30 20:20

    Just to add,

    if you're using many of them then you can import all using

    import 'rxjs/Rx'; 
    

    as mentioned by @Thierry Templier. But I think If you are using limited operator then you should import individual operator like

    import 'rxjs/add/operator/filter';
    import 'rxjs/add/operator/mergeMap';
    import 'rxjs/add/observable/of';
    

    as mentioned by @uksz.

    Because 'rxjs/Rx' will import all the Rx components which definitely cost performance.

提交回复
热议问题