Hi everyone, I am facing an issue in my Angular app where I have two methods getA and getB. I have added a third method getC which is dependent on the results from getB. Can someone guide me on how to properly wait for getB to complete before executing getC? My goal is to be able to use the this.B variable in the getC method.
async ngOnInit() {
await getA();
await getB();
await getC();
}
getA(): void {
this.service.fetchA(this.id)
.pipe(takeUntil(this.ngUnsubscribe))
.subscribe((res) => {
{
this.A = res;
}
});
}
getB(): void {
this.service.fetchB(this.id)
.pipe(takeUntil(this.ngUnsubscribe))
.subscribe((res) => {
this.B = res;
});
}
getC(): void{
this.service.fetchC(this.id).subscribe((res) => {
this.C = this.B + something;
});
}