this.route.params.pipe(
concatMap((param) => {
const ein = param['nonprofit-id'];
return this.nonprofitService.getNonprofit(ein).pipe(
concatMap((nonprofit) => {
this.nonprofit = nonprofit;
const ratingID = nonprofit.currentRating?.ratingID ? nonprofit.currentRating.ratingID : -1;
return this.nonprofitService.getRatingForNonprofit(ein, ratingID).pipe(
concatMap((nonprofitRating) => {
this.nonprofitRating = nonprofitRating;
const causeID = this.nonprofit?.cause?.causeID ? this.nonprofit?.cause?.causeID : 0;
return this.nonprofitService.getSimilarNonprofits(causeID);
})
);
})
);
})
).subscribe((response) => {
this.similarNonprofits = response;
});
I would like to know if the above is the correct way to chain concatMaps in Angular RxJS. The other two calls rely on the "nonprofit" in question being retrieved so that its object can be returned. Rating and Similar Nonprofits can be retrieved at the same time so I was thinking there would be some way I could do this without nesting those concatMaps within each other.