gpt4 book ai didi

Angular 6 ng lint combineLatest 已弃用

转载 作者:太空狗 更新时间:2023-10-29 16:55:45 24 4
gpt4 key购买 nike

我最近从 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 也被弃用以支持其静态版本。

最佳答案

combineLatest is deprecated: resultSelector no longer supported, pipe to map instead

上面的警告是建议删除 resultSelector,这是你在 combineLatest observable 中提供的最后一个函数,并将其作为 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 6 ng lint combineLatest 已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50274275/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com