首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Angular 6,rxjs 6 forkJoin a map

Angular 6,rxjs 6 forkJoin a map
EN

Stack Overflow用户
提问于 2018-10-15 14:54:28
回答 1查看 7.5K关注 0票数 3

这段代码截取后在Angular 4中的工作效果与预期一致:

代码语言:javascript
运行
复制
Observable.forkJoin(
  Observable.of('test1'),
  Observable.of('test2')
).map(result => {
  console.log(result);
}).subscribe();

这段代码在rxjs 6中不再起作用:

代码语言:javascript
运行
复制
forkJoin(
  of('test1'),
  of('test2')
).pipe(map(result => {
  console.log(result);
})).subscribe();

我得到以下编译错误:

代码语言:javascript
运行
复制
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?

EN

回答 1

Stack Overflow用户

发布于 2018-10-15 15:24:48

我自己弄明白了:我从"rxjs/observable/ forkJoin“而不是"rxjs”导入了错误的forkJoin。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52811203

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档