Is there a way to optimize the code below by utilizing behaviorsubjects rather than chaining, ensuring that any failures in function calls do not impact the UI's access to data from other functions?
this.service.getElementById(this.elementId)
.pipe(mergeMap((element) =>
zip(
of(element),
this.service.getReport(this.elementId, this.year, this.month)
))
)
.pipe(mergeMap(([element, report]) =>
zip(
of(element),
of(report),
this.service.getChanges(this.elementId, report.lineId)
))
)
.subscribe(([element, report, changes]) => {
this.paymentProvider = provider;
this.mapToSummary(report);
this.lineId = report.lineId;
this.changes = changes;
})