While exploring Angular rxjs operators, I came across a scenario where I need to send requests to the server that depend on each other. Currently, I have a modal window open and during the ngOnInit lifecycle hook, multiple requests are being sent, some of which are interconnected. However, I have not utilized any rxjs operators in these requests.
For example:
getMyCompanyDetails(){
this.companyService.getCompany('my company name').subscribe(
data => {
// Implement logic here that depends on the second request
}
}
My objective is to sequentially send requests that are dependent on each other, where the second request waits for the first one to complete. I have come across different approaches like switchMap, concatMap, etc., but I am facing challenges in implementing them. I would greatly appreciate your guidance on the best pattern or solution to handle this scenario effectively. Thank you!