Rxjs: Single Observable From Dynamically Created Observables
I am trying to create an observable (fixedObservable here) which will be fed by multiple dynamically created observable over time. Whenever a subscription is made than the subscrib
Solution 1:
using merge, and no need for a subject i guess. Is something like that ok for you?
const dyn1 = Rx.Observable.interval(300)
.timeInterval()
.map(interval => {return {value:interval.value, origin:'dyn1'}});
const dyn2 = Rx.Observable.interval(601)
.timeInterval()
.map(interval => {return {value:interval.value, origin:'dyn2'}});
const m = Rx.Observable.merge(dyn1, dyn2);
m.subscribe(v => console.log(v.value + " from " + v.origin));
Post a Comment for "Rxjs: Single Observable From Dynamically Created Observables"