我最近从Angular 5更新到Angular 6。

我收到此警告combineLatest is deprecated: resultSelector no longer supported, pipe to map instead。 Rxjs是6.1.0版,tslint是5.10.0,Angular CLI是6.0.0和Typescript 2.7.2。我正在这样使用它:

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

我也尝试过这样:
empty().pipe(
combineLatest(...),
  ...
)

但这给了我:combineLatest is deprecated: Deprecated in favor of static combineLatest和empty也被弃用,以支持其静态版本。

最佳答案


上面的警告建议删除resultSelector作为您在CombineLatest中可观察到的最后一个函数,并将其作为map运算符的一部分提供,如下所示

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 is deprecated: Pass arguments in a single array instead,则只需添加[]:
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 - Angular 6 ng Lint 结合最新,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50274275/

10-11 23:44