Created
September 25, 2019 15:25
-
-
Save ganqqwerty/03c277759846b4e62ddcd7c8169ed3a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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