I'm trying to make a function that merges object of rxjs.Observables into single Observable.
For instance,
Suppose that I have a map of observables like following.
const fooObservable$: Observable<Foo> = createFooObservable();
const barObservable$: Observable<Bar> = createBarObservable();
// Type of observables would be
// { foo: Observable<Foo>, bar: Observable<Bar> }
// And, `keyof typeof observables` would be
// "foo" | "bar"
const observables = {
foo: fooObservable$,
bar: barObservable$,
};
then how can I make a function that merges observables like following?
// typeof merged$ would be
// Observable<{ foo: Foo, bar: Bar }>
const merged$ = merge(observables);
I can't figure out how to define the type signature of function merge()
Please give me an answer if there's a good way to do this.