I am using a angular service to wrap some of my http calls in order to manage the loading state of my application.
This service stores the status of the calls for further process. Unfortunately the finalize function is never called.
Here is the wrapper:
searchWithLoader(obs: Observable<any>) {
this.show();
obs.pipe(finalize(() => {
console.log("FINALIZE NOT CALLED");
this.hide();
}));
return obs;
}
And the way I typically call it :
let performanceLoader = this.loaderService.searchWithLoader(
this.performanceDataService.getSomething({
x: x,
y: y,
}));
performanceLoader.subscribe(() => {});
Is there a way around this in order for the finalize to be called in a service instead of the component?