Inflight Cache - luftsport/nlf-client GitHub Wiki

Using the inflight xhr cache

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 => {},
                () => {}
             );