I use shareReplay
to call only once (like a cache) a webservice to retrieve some informations :
In my service :
getProf
Thanks to the answer of martin (which didn't work for me) I found a way to do it :
protected profile: Observable;
private refresh$ = new Subject();
constructor() {
this.profile = this.refresh$.pipe(shareReplay(1));
this.resetProfile();
}
getProfile(): Observable {
return this.profile;
}
resetProfile() {
this.callWS().subscribe(user => {
this.refresh$.next(user);
});
}
I think there is maybe something better/cleaner to do (using a Behavior Subject ?), so if you know something better ..