In our project, we use the following pattern: we do not get the value from the observable, we add the value to the store inside.
loadReport() {
return this.http.get(url, { params: httpParams })
.pipe(
tap(
(obj: X) => {
this.Store.set(obj);
this.rStore.setError(null);
},
e => {
this.Store.setError(e);
}));
}
When I want to update the store I have to call loadReport().subscibe(). But If you use this several times, then several Obsrvables will be created and the request will be sent several times. How can this problem be solved? pipe(first()) and the like don't help. I just need to execute the loadReport method without getting observable, observable and so it is in the store.