今天,我打开我的 Angular 项目,发现一个警告说:
forkJoin is deprecated: resultSelector is deprecated, pipe to map instead (deprecation)
我用谷歌搜索了它,但我发现的很少,我不知道如何摆脱警告。我该如何使用
map
而不是 forkJoin
?
最佳答案
forkJoin
没有被弃用。仅弃用其带有结果选择器功能的变体。
https://github.com/ReactiveX/rxjs/blob/master/src/internal/observable/forkJoin.ts#L29
https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md#howto-result-selector-migration
所以它应该是这样的:
forkJoin(a$, b$, c$).pipe(
map(x => resultSelector(...x))
)
关于Angular:不推荐使用 forkJoin?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54686934/