I am looking for a way to combine multiple Observables into a flat tuple of scalar values - similar to .combineLatest()
- but with the exception that it should emit a new value tuple even when no value has been emitted on one of the source observables - yieldung "undefined" in the tuple for those observables that did not yet emit.
Example:
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
使两个主题开始时具有未定义的值,因此当其中一个主题发出第一个值时,combinateLatest也将发光,并将其与另一个主题的起始值合并。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.