这段代码截取后在Angular 4中的工作效果与预期一致:
Observable.forkJoin(
Observable.of('test1'),
Observable.of('test2')
).map(result => {
console.log(result);
}).subscribe();
这段代码在rxjs 6中不再起作用:
forkJoin(
of('test1'),
of('test2')
).pipe(map(result => {
console.log(result);
})).subscribe();
我得到以下编译错误:
ERROR in app/services/bundles/karaf-bundles.service.ts(47,12): error TS2345: Argument of type 'OperatorFunction<[string, string], void>' is not assignable to parameter of type 'OperatorFunction<any, any>'.
Types of parameters 'source' and 'source' are incompatible.
Type 'Observable<any>' is not assignable to type 'Observable<[string, string]>'.
Types of property 'source' are incompatible.
Type 'import("/Users/moritzvieli/node_modules/rxjs/internal/Observable").Observable<any>' is not assignable to type 'import("/Users/moritzvieli/repo/cltmgmtconsole/web/node_modules/rxjs/internal/Observable").Observ...'.
Types of property 'source' are incompatible.
Type 'import("/Users/moritzvieli/node_modules/rxjs/internal/Observable").Observable<any>' is not assignable to type 'import("/Users/moritzvieli/repo/cltmgmtconsole/web/node_modules/rxjs/internal/Observable").Observ...'.
如何在Angular 6中映射forkjoin?
发布于 2018-10-15 15:24:48
我自己弄明白了:我从"rxjs/observable/ forkJoin“而不是"rxjs”导入了错误的forkJoin。
https://stackoverflow.com/questions/52811203
复制相似问题