-
Notifications
You must be signed in to change notification settings - Fork 1
Inflight Cache
einarhuseby edited this page Feb 8, 2019
·
1 revision
Configure (optional) options then wrap the GET in apiCache.get. Cache is stored in-memory in users browser and will be cleared on logout or closing window/tab.
import { ApiCacheService } from 'app/api/api-cache.service';
constructor(private service: Service,
private apiCache: ApiCacheService) { }
...
const options: ApiOptionsInterface = {
query: { projection: { fullname: 1 } }
};
this.apiCache.get(
['unique-key', this.id, options.query],
this.service.getSomething(this.id, options)
).subscribe(
data => {}
err => {},
() => {}
);