rxjs/Subscription has no exported member 'Subscription'

前端 未结 4 2081
说谎
说谎 2020-12-09 09:10

I updated my angular project and all my dependencies to latest version. Without to much trouble I solved most of the dependency issues, but I\'m still stuck on RxJS. Here is

相关标签:
4条回答
  • 2020-12-09 09:27

    You can fix it with this:

    import {from} from 'rxjs';

    And, instead of: return Observable.fromPromise(new Promise((resolve, reject) => {

    Now just do:

    return from(new Promise((resolve, reject) => {

    The same applies to Observable.of

    0 讨论(0)
  • 2020-12-09 09:38

    There is a lot of breaking changes with RxJS 6. For example, prototype methods as

    myObservable.map(data => data * 2)
    

    won't work anymore and must be replaced by

    myObservable.pipe(map(data => data * 2))
    

    All details can be found here: https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md


    Until you have fixed all breaking changes, you can make your old code work again with rxjs-compat (https://github.com/ReactiveX/rxjs/tree/master/compat).

    This package is required to get backwards compatibility with RxJS previous to version 6. It contains the imports to add operators to Observable.prototype and creation methods to Observable.

    Type this to install it:

    npm install -s rxjs-compat
    
    0 讨论(0)
  • 2020-12-09 09:38

    I hope your problem will resolve using this below statement import Subscription from 'rxjs'

    0 讨论(0)
  • 2020-12-09 09:41

    afaik Angular 6 and rxjs 6 are not already compatible, for the compatibility they created https://www.npmjs.com/package/rxjs-compat you have to install

    [UPDATE] fromPromise is now "from". see here : https://github.com/ReactiveX/rxjs/issues/3525

    0 讨论(0)
提交回复
热议问题