At times, I find myself in need of a value from a previous observable in order to run another function that relies on that value, creating a chain of dependencies. This often results in nested subscribe() calls, making the code messy and hard to manage. Here's an example:
getObservableData().subscribe(next=>
let dialogRef=this.dialog.open(EvalListComponent, {data: next})
dialogRef.afterClosed().subscribe(next=>{
let k=dialogRef.componentInstance.getAnotherObservableData()
.subscribe( next=> doSomething(next))
}))
What is the best approach for handling such situations? I want to flatten the structure and avoid nested subscriptions. I am aware of the pipe function and its usage with rxjs operators, but how can this be achieved?