[英]How to get “Observable.of([]);” to work?
What is the correct expression and import for Observable.of([]);
Observable.of([]);
的正确表达和导入是什么Observable.of([]);
. 。
import { of } from 'rxjs';
does not work for me. 不适合我。
Since RxJS 6 you should import all "creation" observables directly from 'rxjs'
(assuming you have path maps set when bundling your app). 从RxJS 6开始,您应该直接从
'rxjs'
导入所有“创建”可观察'rxjs'
(假设您在捆绑应用程序时设置了路径映射 )。
More detailed explanation: https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md#import-paths 更详细的解释: https : //github.com/ReactiveX/rxjs/blob/master/MIGRATION.md#import-paths
import { of } from 'rxjs';
of(1).subscribe(console.log);
See demo: https://stackblitz.com/edit/typescript-e3lxkb?file=index.ts 请参阅演示: https : //stackblitz.com/edit/typescript-e3lxkb?file = index.ts
无需使用Observable.of(T)而是可以在rxjs 6.3.3中使用以下语法
return new Observable<AppUser>();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.