I've created a demo (ng-run) where I have a button which invokes an Http request.
When the button is clicked, I invoke this method :
public getData(){
this._jokeService.getData().subscribe();
}
Which in turn invokes this ( from a service) :
public getData() {
return this.http.get(API_ENDPOINT).pipe(shareReplay(1))
}
The problem is that on every click - I still see a new http request initiated :
Question:
Why doesn't shareReplay keeps the last value of the response?
How can I make my code to invoke the http only once and keep that value for future subscriptions ?
Edit: solution is here