在我的应用程序中我有类似的东西:
this._personService.getName(id)
.concat(this._documentService.getDocument())
.subscribe((response) => {
console.log(response)
this.showForm()
});
//Output:
// [getnameResult]
// [getDocumentResult]
// I want:
// [getnameResult][getDocumentResult]
Run Code Online (Sandbox Code Playgroud)
然后我得到两个分开的结果,第一个_personService
然后是_documentService
.如何在调用之前等待两个结果this.showForm()
然后操纵每个结果.
使用后运行rxjs迁移工具
rxjs-5-to-6-migrate -p src/tsconfig.app.json
我现在得到一个linting错误:
combineLatest已弃用:不赞成使用static 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;
});
Run Code Online (Sandbox Code Playgroud)
运行迁移命令后的代码:(当前显示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;
});
Run Code Online (Sandbox Code Playgroud)
问题在这个stackoverflow问题中被问到,但它不够具体:Angular 6 ng lint重复错误和警告,combineLatest已被弃用 .