Within my Angular 14 application, I am faced with a scenario where I need to make two API calls and then combine the results using "combineLatest" from rxjs. The combined data is then assigned to a variable that I must use in a separate function. How can I ensure that this second function is only called once the data has been obtained?
I understand that an immediate solution would be to place the call to the second function inside the "combineLatest" block, but unfortunately, this approach is not feasible for me. Is there a method available to guarantee that the second function is triggered only when the necessary data is present?
Presented below is an excerpt of my code:
this.dataSubscription = combineLatest([aaaSubscription, bbbObservable]).subscribe(result => {
this.someVariable = result[0];
}
separateFunction() {
if(this.someVariable) {
console.log("Do this")
}