In my Angular 14 application, I am making 2 API calls and then combine them using “combineLatest” from rxjs and then assigning the data to a variable.
I have to use that data/variable in a seperate function. How do I make sure that the second function ( seperate function ) is called only once the data/variable.
I understand that a simple solution will be to call the second function inside the “combineLatest” block but unfortunately I cannot do that. Is there a way to make sure that the second function is called only when the data is available.
Here is my sample code:
this.dataSubscription = combineLatest([aaaSubscription, bbbObservable]).subscribe(result => {
this.someVariable = result[0];
}
seperateFunction() {
if(this.someVariable) {
console.log("Do this")
}