Skip to content

Instantly share code, notes, and snippets.

@ganqqwerty
Created September 25, 2019 15:25
Show Gist options
  • Save ganqqwerty/03c277759846b4e62ddcd7c8169ed3a1 to your computer and use it in GitHub Desktop.
Save ganqqwerty/03c277759846b4e62ddcd7c8169ed3a1 to your computer and use it in GitHub Desktop.
resolveProduct(code: string): Observable<any> {
if (this.cache[code]) {
console.log('Returning cached value!')
return this.cache[code];
}
console.log('Do the request again')
this.cache[code] = this.http.get(this.URL+code+'.json').pipe(
shareReplay(1),
catchError(err => {
delete this.cache[code];
return EMPTY;
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment