Hi all In my angular app I have two methods getA and getB. I've added third one getC that is dependent on results from getB. How can I wait for getB to complete ? I want to use this.B variable in 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;
});
}