Previously, I utilized Promise with async/await syntax in my Typescript code like this:
const fooData = await AsyncFooData();
const barData = await AsyncBarData();
... perform actions using fooData and barData
However, when using RxJs Observable<T>
, the structure changes to something like:
AsyncFooData().subscribe(fooData => {
AsyncBarData().subscribe(barData => {
... perform actions using fooData and barData
})
})
Is there a more efficient approach to handle this? The nested subscriptions can make the code less readable, especially if dealing with multiple AsyncData sources.