不推荐使用 combineLatest 以支持静态 combineLatest [英] combineLatest deprecated in favor of static combineLatest
问题描述
使用后运行 rxjs 迁移工具
After running the rxjs migration tool using
rxjs-5-to-6-migrate -p src/tsconfig.app.json
rxjs-5-to-6-migrate -p src/tsconfig.app.json
我现在收到一个 linting 错误:
I'm now getting a linting error:
combineLatest 已弃用:已弃用,支持静态结合最新.
combineLatest is deprecated: Deprecated in favor of static combineLatest.
这是我运行迁移命令之前的代码:
Here is my code before running the migration command:
this.store.combineLatest(
this.store.select(lang.getCurrent),
this.store.select(lang.getCurrentLocale)
).subscribe(([state, currentLang, locale]) => {
this._language = session.language === currentLang ? '' : currentLang;
this._locale = session.locale === locale ? '' : locale;
});
我运行迁移命令后的代码:(当前呈现 linting 错误)
My code after running the migration command: (currently presenting a linting error)
import {map, combineLatest} from 'rxjs/operators';
this.store.combineLatest(
this.store.select(lang.getCurrent),
this.store.select(lang.getCurrentLocale)
).subscribe(([state, currentLang, locale]) => {
this._language = session.language === currentLang ? '' : currentLang;
this._locale = session.locale === locale ? '' : locale;
});
在这个stackoverflow问题中提出了这个问题,但不够具体:Angular 6 ng lint 重复错误和警告,不推荐使用 combineLatest.
The question was asked in this stackoverflow questions, but it was not specific enough: Angular 6 ng lint duplicate errors and warnings, combineLatest is deprecated .
推荐答案
已弃用!
请参阅 关于 RxJs 6.5 中正确语法的 fridman 的回答
我在这篇文章中找到了答案:RxJS 6: What's new以及发生了什么变化?(来自 官方文档):
I found an answer in this article titled: RxJS 6: What's new and what has changed? ( which comes from official docs):
解决方法是转换:
import { combineLatest } from 'rxjs/operators';
a$.pipe(combineLatest(b$, c$));
进入:
import { combineLatest } from 'rxjs';
combineLatest([a$, b$, c$]);
这篇关于不推荐使用 combineLatest 以支持静态 combineLatest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!