I need to call two http service calls and subscribe them after subscribing another one http service call. I mean, the operation will be sequential as the last two calls depend on the first one. Can this operation be handled with concatMap of RxJs?
I solved the problem using nested subscription. But, I think using concatMap, this can be done. In all examples I searched, there are two calls which are concatenated. How to concat more than two subscription and solve the issue.
this.accountService.fetchBranchCodeLength().subscribe(
data => {
this.branchCodeLength = +data;
//Now, I need to call another service to calculate
accountNumberLengthWithProductCode//
this.subscribers.fetchAcoountNumberLength =
this.accountService.fetchAccountLengthConfiguration().subscribe(
accountLength => {
this.accountNumberLengthWithProductCode =
(+accountLength) - (+this.branchCodeLength);});
//Another same kind of call to calculate
SUBGLCodeLength//
this.subscribers.fetchSUBGLCodeLengthSub =
this.glAccountService.fetchSUBGlCodeLength(SUBGlCodeQueryParam)
.subscribe(length => this.SUBGLCodeLength =
(+length.value) - (+this.branchCodeLength)
);
}
);
concatMap; see stackoverflow.com/questions/40651060/… - diEcho