http1$, http2$, http3$, http4$ are API requests made using angular HTTP client library
this.apiService
.http1$
.pipe(
concatMap((http1Result: any) => {
// I have status property returned in response if there is any error,
// use catchError operator if 500 or other errors are returned in your APIs
if (!http1Result.status) {
// Stop the observable chain.
return EMPTY;
}
// If no error, call next API.
return this.apiService.http2$;
}),
concatMap((http2Res: any) => {
if (!http2Res.status) {
return EMPTY;
}
return this.apiService.http3$;
}),
concatMap((http3Result: any) => {
if (!http3Result.status) {
// Do something
}
return this.apiService.http4$;
})
)
.subscribe((result: any) => {
console.log('Final Subscribe: ');
console.log(result);
// Do some thing you want.
});
Ref: Good resource on different operators https://blog.angular-university.io/rxjs-higher-order-mapping/
Error handling https://blog.angular-university.io/rxjs-error-handling/