Angular Rxjs 6相当于Observable.create(订户->;{…}).share()
我正在将Angular 5应用程序升级到Angular 6,因此从rxjs 5升级到rxjs 6,在迁移以下代码时遇到了问题:Angular Rxjs 6相当于Observable.create(订户->;{…}).share(),angular,typescript,rxjs,observable,rxjs6,Angular,Typescript,Rxjs,Observable,Rxjs6,我正在将Angular 5应用程序升级到Angular 6,因此从rxjs 5升级到rxjs 6,在迁移以下代码时遇到了问题: const myObservable = Observable.create(subscriber => { // do something with the subscriber }).share(); 特别是我得到了这个错误: TypeError:Observable_1.Observable.create(…)。共享不是一个 functionTyp
const myObservable = Observable.create(subscriber => {
// do something with the subscriber
}).share();
特别是我得到了这个错误:
TypeError:Observable_1.Observable.create(…)。共享不是一个
functionTypeError:Observable_1.Observable.create(…)。共享不可用
上面的代码应该可以做到这一点您需要按如下方式管道共享(),而不是链接:
const myObservable = Observable.create(subscriber => {
// do something with the subscriber
}).pipe(share());
另外,请确保按如下方式导入共享:
import {share} from 'rxjs/operators';
import {share} from 'rxjs/operators';