我正在使用RxJS 6,该版本现在使用管道运算符。我有这个:
import {Observable, ReplaySubject} from 'rxjs';
const rs1 = new ReplaySubject(1);
const rs2 = new ReplaySubject(1);
const rs3 = new ReplaySubject(1);
rs1.next(1);
rs2.next(2);
rs3.next(3);
Observable.merge(rs1,rs2,rs3).subscribe(v => {
});
但这不能编译-未定义Observable.merge。我可能正在寻找concat而不是merge,但是无论哪种方式,concat都没有在Observable构造函数上定义为静态方法-我们如何在RxJS7中使用merge和concat?
答案 0 :(得分:0)
他们在版本6中做了一些更改,现在对我有用:
import {concat, Observable, merge} from 'rxjs';
import {BehaviorSubject, ReplaySubject, pipe} from "rxjs";
import {takeUntil, takeWhile} from 'rxjs/operators';
const rs1 = new ReplaySubject(1);
const rs2 = new ReplaySubject(1);
const rs3 = new ReplaySubject(1);
rs1.next(1);
rs2.next(2);
rs3.next(2);
merge(rs1,rs2,rs3).pipe(takeWhile(() => true)).subscribe(v => {
console.log({v});
});