Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
feat(store): add methods to interact with cache
Browse files Browse the repository at this point in the history
Closes: #241
  • Loading branch information
rayrutjes committed Aug 5, 2017
1 parent 864e543 commit 98406fb
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export class Store {
this._highlightPreTag = '<em>';
this._highlightPostTag = '</em>';

this._cacheEnabled = true;

this.algoliaHelper = helper;
}

Expand Down Expand Up @@ -355,11 +357,25 @@ export class Store {
};
}

// Todo: find a better name for this function.
refresh() {
if (this._cacheEnabled === false) {
this.clearCache();
}
this._helper.search();
}

enableCache() {
this._cacheEnabled = true;
}

disableCache() {
this._cacheEnabled = false;
}

clearCache() {
this.algoliaClient.clearCache();
}

waitUntilInSync() {
return new Promise((resolve, reject) => {
if (this._helper.hasPendingRequests() === false) {
Expand Down

0 comments on commit 98406fb

Please sign in to comment.