DS#refresh
DS#refresh(resourceName, id[, options])
Like DS#find
, except the item is only re-requested from the adapter if it already exists in the data store.
Returns a promise.
Arguments
name | type | description |
---|---|---|
resourceName | string | The name of the resource to use. Unnecessary if using the resource directly. |
id | string or number | The primary key of the item to retrieve. |
options | object | Configuration options. Also passed through to the adapter and (conditionally) to DS.inject . |
options.adapter | string | Override the default adapter. |
options.cacheResponse | boolean | Inject the result into the store. Default: true . |
Examples
// Exists in the data store, but we want a fresh copy
Document.get(5); // {...}
// Same as store.refresh('document', 5);
Document.refresh(5).then(function (document) {
document; // The fresh copy, already injected into the store
});
// Does not exist in the data store
Document.get(6); // undefined
Document.refresh(6).then(function (document) {
document; // undefined
});
Need help?
Want more examples or have a question? Ask on the Slack channel or post on the mailing list then we'll get your question answered and probably update this wiki.
Updated less than a minute ago