【问题标题】:How to use static combineLatest correctly如何正确使用静态 combineLatest
【发布时间】:2019-07-17 08:17:50
【问题描述】:

RxJS v.6.5 开始,静态combineLatest 语法 combined$ = combineLatest(a$,b$,c$); 已弃用。

您应该使用以下语法:

combined$ = combineLatest([a$,b$,c$]);

他们在哪里:a$: Observable<T>, b$: Observable<U>, c$: Observable<V>

这个声明虽然给了我几个 linting 错误:

参数类型 [Observable>>, Observable>>, Observable>>] 不可分配给 参数类型 [Observable>>]

那么,我的错误在哪里? 非常感谢。

【问题讨论】:

  • 你能显示你的代码吗..?

标签: rxjs combinelatest


【解决方案1】:

您应该像这样从rxjs 导入combineLatest 而不是rxjs/operators

import { of, combineLatest } from 'rxjs';

const a$ = of(true);
const b$ = of(false);

combineLatest([a$, b$]).pipe(
      tap(console.log)
    ).subscribe();

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-31
    • 2012-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-23
    • 1970-01-01
    相关资源
    最近更新 更多