mirror of
https://github.com/nasa/openmct.git
synced 2025-06-12 20:28:14 +00:00
[Core] Add JSDoc to PersistenceCapability
Add JSDoc to PersistenceCapability, to continue satisfying code standards in preparation for integration of the platform/core bundle. WTD-573.
This commit is contained in:
@ -1,20 +1,35 @@
|
|||||||
/*global define*/
|
/*global define*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines the "persistence" capability, used to indicate
|
|
||||||
* that changes to an object should be written to some
|
|
||||||
* underlying store.
|
|
||||||
*
|
|
||||||
* Current implementation is a stub that simply triggers
|
|
||||||
* a refresh on modified views, which is a necessary
|
|
||||||
* side effect of persisting the object.
|
|
||||||
*/
|
|
||||||
define(
|
define(
|
||||||
function () {
|
function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the `persistence` capability, used to trigger the
|
||||||
|
* writing of changes to a domain object to an underlying
|
||||||
|
* persistence store.
|
||||||
|
*
|
||||||
|
* @param {PersistenceService} persistenceService the underlying
|
||||||
|
* provider of persistence capabilities.
|
||||||
|
* @param {string} SPACE the name of the persistence space to
|
||||||
|
* use (this is an arbitrary string, useful in principle
|
||||||
|
* for distinguishing different persistence stores from
|
||||||
|
* one another.)
|
||||||
|
* @param {DomainObject} the domain object which shall expose
|
||||||
|
* this capability
|
||||||
|
*
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
function PersistenceCapability(persistenceService, SPACE, domainObject) {
|
function PersistenceCapability(persistenceService, SPACE, domainObject) {
|
||||||
var self = {
|
return {
|
||||||
|
/**
|
||||||
|
* Persist any changes which have been made to this
|
||||||
|
* domain object's model.
|
||||||
|
* @returns {Promise} a promise which will be resolved
|
||||||
|
* if persistence is successful, and rejected
|
||||||
|
* if not.
|
||||||
|
*/
|
||||||
persist: function () {
|
persist: function () {
|
||||||
return persistenceService.updateObject(
|
return persistenceService.updateObject(
|
||||||
SPACE,
|
SPACE,
|
||||||
@ -22,15 +37,20 @@ define(
|
|||||||
domainObject.getModel()
|
domainObject.getModel()
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Get the space in which this domain object is persisted;
|
||||||
|
* this is useful when, for example, decided which space a
|
||||||
|
* newly-created domain object should be persisted to (by
|
||||||
|
* default, this should be the space of its containing
|
||||||
|
* object.)
|
||||||
|
*
|
||||||
|
* @returns {string} the name of the space which should
|
||||||
|
* be used to persist this object
|
||||||
|
*/
|
||||||
getSpace: function () {
|
getSpace: function () {
|
||||||
return SPACE;
|
return SPACE;
|
||||||
},
|
|
||||||
invoke: function () {
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return PersistenceCapability;
|
return PersistenceCapability;
|
||||||
|
Reference in New Issue
Block a user