在运行rxjs迁移工具之后,使用
迁移-p src/tsconfig.app.json
我现在得到了一个衬里错误:
不建议使用combineLatest :不推荐使用静态combineLatest。
在运行迁移命令之前,下面是我的代码:
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错误)
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;
});这个问题是在这个堆栈溢出问题中提出的,但是它还不够具体:角6ng的重复错误和警告,combineLatest是不推荐的。
发布于 2018-05-10 15:24:37
不赞成!
请参阅ofir fridman对RxJ6.5中正确句法的回答
我在这篇题为:RxJS 6:什么是新的,什么改变了? (来自官方文件)的文章中找到了一个答案:
解决办法是转换:
import { combineLatest } from 'rxjs/operators';
a$.pipe(combineLatest(b$, c$));转入:
import { combineLatest } from 'rxjs';
combineLatest([a$, b$, c$]);发布于 2019-05-19 14:05:54
在rxjs 6.5+中
import { combineLatest } from 'rxjs';
combineLatest([a$, b$, c$]);对于大多数应用程序来说,将可观察到的数组映射到一个新值也是有帮助的:
combineLatest([a$, b$, c$]).pipe(
map(([a$, b$, c$]) => ({
a: a$,
b: b$,
c: c$
}))
);另见:https://www.learnrxjs.io/learn-rxjs/operators/combination/combinelatest
发布于 2019-04-03 10:43:49
rxjs版本6.4.0
您应该从RxJs运算符中导入map运算符以使其工作。
combineLatest(a$, b$, c$).pipe(map([a, b, c]) => treat(a, b, c))
https://stackoverflow.com/questions/50276165
复制相似问题