mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 21:57:50 +08:00

Sometimes you want stale data right away, then refresh it async. This adds `findStale` to the store for that case. If it returns an object with `hasResults` you can get the `results` and display them. It also returns a `refresh()` method to freshen up the stale data. To enable `localStorage` support for stale data, just include the mixin `StaleLocalStorage` into an adapter for that model. This commit includes a sample of doing that for `Notifications`.
13 lines
228 B
JavaScript
13 lines
228 B
JavaScript
const StaleResult = function() {
|
|
this.hasResults = false;
|
|
};
|
|
|
|
StaleResult.prototype.setResults = function(results) {
|
|
if (results) {
|
|
this.results = results;
|
|
this.hasResults = true;
|
|
}
|
|
};
|
|
|
|
export default StaleResult;
|