I have a code snippet where I have nested subscribe functions, and while it works, the structure is not ideal. I am looking to refactor this code using rxjs (forkjoin or mergemap) but I am unsure how to do so. Any assistance in helping me optimize this would be greatly appreciated.
this.chapservice.cycle().subscribe((current) => {
this.selectedCycleId = current.ratingCycleId;
this.chapService
.getChapterEvalWithSkills(
this.activeUser.ipn,
this.selectedRatingCycleId
)
.subscribe((response) => {
console.log("response", response);
if (response && response.length > 0) {
this.chapterEvals = response;
}
});
this.chapservice
.getIsitEmployeeStatus(this.activeUser.ipn, this.selectedCycleId)
.subscribe((sdpStatus) => {
this.activeUserStatus = sdpStatus;
if (this.activeUserStatus.statusDescription == 'SUBMITTED') {
//do something
}
});
});