In the below code I have used subscribe inside subscribe. This code works but the code structure is very bad. I would like to refactor this code using rxjs(forkjoin or mergemap).I'm not sure how to achieve this. Can someone help me with this? Any help is 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
}
});
});