Could not use Observable.of in RxJs 6 and Angular 6

后端 未结 3 721
春和景丽
春和景丽 2020-12-08 09:23
 import { Observable, of } from \"rxjs\";

// And if I try to return like this
  return Observable.of(this.purposes);

I am getting an error stating

3条回答
  •  猫巷女王i
    2020-12-08 10:14

    Looks like cartant's comment is correct, the RxJS upgrade guide doesn't cover that method specifically but does say "Classes that operate on observables have been replaced by functions"

    Which seems to mean all or most of those class methods like .of, .throw etc. have been replaced by a function

    So instead of

    import { Observable, of } from "rxjs";
    Observable.of(this.purposes);
    

    do

    import { of } from "rxjs";
    of(this.purposes);
    

提交回复
热议问题