Skip to content

Instantly share code, notes, and snippets.

@KhodeN
Created March 30, 2018 05:38
Show Gist options
  • Save KhodeN/eb7d9667b48c0211d4d83fcaf98003df to your computer and use it in GitHub Desktop.
Save KhodeN/eb7d9667b48c0211d4d83fcaf98003df to your computer and use it in GitHub Desktop.
class MySuperService {
cache: {
[key:string] : Observable<IMyEntity>
} = {};
getItem(id number){
let promise = this.cache[id];
if (!promise){
promise = this._http.get<IMyEntity>('/entities');
this.cache[id] = promise;
}
return promise;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment