I would like to add a waiting bar line this to make user to wait until all the necessary data are retrieved.
The problem is that I have several HTTP call so I don't know if exist a simple way to catch the end of all these request (I thought about a counter that I increment for each end of call at only when all the methods end I have to hide the waiting bar).
Since this is a common problem, there is a simple way to make this?
For example this is a component code:
ngOnInit() {
this.spinner.show();
call1();
call2();
call3();
.....
callN();
//At the end of all method
this.spinner.hide();
}
call1() {
this.service.getAtti().subscribe((apiResult: ApiResult<a[]>) => {
this.a = apiResult.Data;
}
);
}
call2() {
this.service.getDestinatari().subscribe((apiResult: ApiResult<b[]>) => {
this.b = apiResult.Data;
}
);
}
call3() {
this.service.getRichiedenti().subscribe((apiResult: ApiResult<c[]>) => {
this.c = apiResult.Data;
}
);
}
callN() {
this.service.getMessi().subscribe((apiResult: ApiResult<d[]>) => {
this.d = apiResult.Data;
}
);
}