There is a button on my page that generates a report. This report needs data that is downloaded using an HTTP call to the resting point when the page loads, but I have no guarantee that it loads when the user clicks the report button. How can I execute a whitch observable if it is completed, and if it is not completed, in order to wait for the action until the HTTP call is completed? Here is the piece of code:
loadCompanies(): void {
this._companyService.getCompanies().subscribe(
response => {
this.companiesModel = response;
},
err => console.log(err)
);
}
......
generateReport() {
}
One option is with the flag set in the company downloads with the values loaded, “completed” and waiting in generateReport () until the flag is complete. But I would prefer a solution using observable api if possible.
Any tips or helpful links are welcome. Thank.