UNPKG

@atlaskit/global-search

Version:

A cross-product search component (batteries included)

18 lines (15 loc) 680 B
import ConfluenceClientImpl from './ConfluenceClient'; import { SimpleCache } from '../util/simple-cache'; export default class CachingConfluenceClient extends ConfluenceClientImpl { constructor(url, prefetchedResults) { super(url); this.itemCache = new SimpleCache(prefetchedResults && prefetchedResults.then(result => result.objects.items), () => super.getRecentItems()); this.spaceCache = new SimpleCache(prefetchedResults && prefetchedResults.then(result => result.spaces.items), () => super.getRecentSpaces()); } async getRecentItems() { return await this.itemCache.get(); } async getRecentSpaces() { return await this.spaceCache.get(); } }