I've implemented this method in a certain way, but I'm feeling a bit uneasy about it as I'm not entirely sure if it's considered acceptable practice or just a workaround. Can someone please advise me on whether this is a hack or a valid approach?
The reason behind my implementation is to ensure that the first method finishes executing before the second one starts.
If this is indeed bad practice (which I suspect), I would greatly appreciate suggestions on how to improve this code.
Essentially, I have one method that invokes an HTTP GET request and then, upon subscription, calls another method which in turn interacts with another service using the retrieved data.
private bind(): void {
this.Service.get(this.Id)
.catch(this.logger.log)
.subscribe(
(customers: PersonalInfo[]) => {
this.customers = customers;
this.bindContactInfo();
}
);
}
private bindContactInfo():void{
this.Service.getContactInfo(this.Id)
.catch(this.logger.log)
.subscribe(
(contactInfo: ContactInformation[]) => {
// operations here
}
);
}