rxjs/Subscription has no exported member 'Subscription'

◇◆丶佛笑我妖孽 提交于 2019-11-30 06:39:34

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

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

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

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

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