-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cache disabling for datasets #254
Conversation
This one definitely sounds like the more reasonable of both PRs, @samouss, what do you think? |
src/autocomplete/dataset.js
Outdated
@@ -37,6 +37,8 @@ function Dataset(o) { | |||
|
|||
this.debounce = o.debounce; | |||
|
|||
this.disableCache = !!o.disableCache; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would go for enableCache
(or something similar) with a default value to true
rather than disableCache
. Positive condition are a bit easier to reason about.
src/autocomplete/dataset.js
Outdated
@@ -235,6 +237,10 @@ _.mixin(Dataset.prototype, EventEmitter, { | |||
}, | |||
|
|||
shouldFetchFromCache: function shouldFetchFromCache(query) { | |||
if (this.disableCache) { | |||
return false; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we have inverted the condition we can inline the condition.
@Haroenv The tests are failing because of the Netlify ENV variable not available on contributors PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes! For the option name we can go for cache
rather than enableCache
no? WDYT? cc @Haroenv
Agreed with @samouss, |
…ete.js into dataset-disable-cache
Summary
Adds the ability to disable cache retrieval of subsequent identical queries via a boolean flag in dataset config called
disableCache
.Use case:
Related issues:
Additional notes: