Dyna Dyna - 7 months ago 38
Javascript Question

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

I am looking for a way to combine multiple Observables into a flat tuple of scalar values - similar to

- 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.


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

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


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


Make the two subjects startWith the undefined value, so when one of then emits the first value, the combineLatest will emit as well and combine that with the start value of the other subject.