Angular 6 ng lint combineLatest 已弃用 [英] Angular 6 ng lint combineLatest is deprecated

查看:54
本文介绍了Angular 6 ng lint combineLatest 已弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近从 Angular 5 更新到了 Angular 6.

I recently updated from Angular 5 to Angular 6.

我收到此警告 combineLatest 已弃用:不再支持 resultSelector,改为使用管道映射.Rxjs 是 6.1.0 版本,tslint 是 5.10.0,Angular CLI 是 6.0.0 和 Typescript 2.7.2.我是这样使用它的:

I'm getting this warning combineLatest is deprecated: resultSelector no longer supported, pipe to map instead. Rxjs is version 6.1.0, tslint is 5.10.0, Angular CLI is 6.0.0 and Typescript 2.7.2. I'm using it like this:

const a$ = combineLatest(
  this.aStore.select(b.getAuth),
  this.cStore.select(b.getUrl),
  (auth, url) => ({auth, url}),
);

我也这样试过:

empty().pipe(
combineLatest(...),
  ...
)

但这给了我:combineLatest 已弃用:已弃用,以支持静态 combineLatest 和 empty 也已弃用,以支持其静态版本.

But this gives me: combineLatest is deprecated: Deprecated in favor of static combineLatest and empty is also deprecated in favor of its static version.

推荐答案

combineLatest 已弃用:不再支持 resultSelector,改为使用管道映射

上述警告建议删除您在 combineLatest observable 中提供的最后一个函数 resultSelector 并将其作为地图运算符的一部分提供,如下所示

The above warning is recommending to remove the resultSelector the last function you provided in combineLatest observable and provide it as part of map operator as follows

const a$ = combineLatest(
  this.aStore.select(b.getAuth),
  this.cStore.select(b.getUrl)
);

const result$ = a$.pipe(
  map(results => ({auth: results[0], url: results[1]}))
)

更新:

如果您看到 combineLatest 已被弃用:改为在单个数组中传递参数 那么只需添加 []:

If you see combineLatest is deprecated: Pass arguments in a single array instead then just add []:

const a$ = combineLatest([
  this.aStore.select(b.getAuth),
  this.cStore.select(b.getUrl)
]);
    
const result$ = a$.pipe(
  map(results => ({auth: results[0], url: results[1]}))
)

这篇关于Angular 6 ng lint combineLatest 已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆