mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 23:28:14 +00:00
[Persistence] Add refresh
Continue adding behavior for persistence failures; add a refresh method to the persistence capability to support this. WTD-1033.
This commit is contained in:
@ -22,6 +22,13 @@ define(
|
||||
* @constructor
|
||||
*/
|
||||
function PersistenceCapability(persistenceService, SPACE, domainObject) {
|
||||
// Update a domain object's model upon refresh
|
||||
function updateModel(model) {
|
||||
return domainObject.useCapability("mutation", function () {
|
||||
return model;
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
/**
|
||||
* Persist any changes which have been made to this
|
||||
@ -37,6 +44,19 @@ define(
|
||||
domainObject.getModel()
|
||||
);
|
||||
},
|
||||
/**
|
||||
* Update this domain object to match the latest from
|
||||
* persistence.
|
||||
* @returns {Promise} a promise which will be resolved
|
||||
* when the update is complete
|
||||
*/
|
||||
refresh: function () {
|
||||
return persistenceService.readObject(
|
||||
SPACE,
|
||||
domainObject.getId(),
|
||||
{ cache: false } // Disallow cached reads
|
||||
).then(updateModel);
|
||||
},
|
||||
/**
|
||||
* Get the space in which this domain object is persisted;
|
||||
* this is useful when, for example, decided which space a
|
||||
|
Reference in New Issue
Block a user