RxJS 运算符类似于 .combineLatest 但只要单个可观察对象发出就会触发

RxJS5 operator similiar to .combineLatest but fire whenever a single observable emits

我正在寻找一种方法将多个 Observables 组合成标量值的平面元组——类似于 .combineLatest()——但除了它应该发出一个新的值元组,即使没有发出任何值在其中一个源 observables 上 - yieldung "undefined" 在那些尚未发出的 observables 的元组中。

示例:

const s1 = new Subject<string>();
const s2 = new Subject<string>();

Observable.combineWithUndefined(s1, s2).subscribe( ([t1, t2]) => {
    console.log(t1.toString() + " " + t2.toString());
});

s1.next("Hello");
s2.next("John");

// expected output:
// Hello undefined
// Hello John

使两个主题 startWith 成为未定义的值,因此当其中一个发出第一个值时,combineLatest 也会发出并将其与另一个主题的起始值组合。