[API] Clean up Composition API

This commit is contained in:
Victor Woeltjen 2016-09-07 08:09:37 -07:00
parent 5a129de73d
commit 851d0f0d63
2 changed files with 43 additions and 7 deletions

View File

@ -49,6 +49,21 @@ define([
*/
this.conductor = new TimeConductor();
/**
* An interface for interacting with the composition of domain objects.
* The composition of a domain object is the list of other domain
* objects it "contains" (for instance, that should be displayed
* beneath it in the tree.)
*
* `composition` may be called as a function, in which case it acts
* as [`composition.get`]{@link module:openmct.CompositionAPI#get}.
*
* @type {module:openmct.CompositionAPI}
* @memberof module:openmct.MCT#
* @name composition
*/
this.composition = api.Composition;
this.TimeConductor = this.conductor; // compatibility for prototype
this.on('navigation', this.selection.clear.bind(this.selection));
}
@ -66,7 +81,7 @@ define([
*
* @type {module:openmct.ObjectAPI}
* @memberof module:openmct.MCT#
* @name Objects
* @name objects
*/
MCT.Objects = api.Objects;
@ -76,7 +91,7 @@ define([
*
* @type {module:openmct.TelemetryAPI}
* @memberof module:openmct.MCT#
* @name Telemetry
* @name telemetry
*/
MCT.prototype.legacyExtension = function (category, extension) {

View File

@ -19,13 +19,14 @@ define([
};
/**
* Retrieve the composition (if any) of this domain object. The
* composition of a domain object is the list of other domain objects
* An interface for interacting with the composition of domain objects.
* The composition of a domain object is the list of other domain objects
* it "contains" (for instance, that should be displayed beneath it
* in the tree.)
* @method Composition
*
* @interface CompositionAPI
* @returns {module:openmct.CompositionCollection}
* @memberof module:openmct.MCT#
* @memberof module:openmct
*/
function composition(object) {
var provider = getProvider(object);
@ -35,8 +36,28 @@ define([
}
return new CompositionCollection(object, provider);
};
}
/**
* Retrieve the composition (if any) of this domain object.
*
* @method get
* @returns {module:openmct.CompositionCollection}
* @memberof module:openmct.CompositionAPI#
*/
composition.get = composition;
/**
* Add a composition provider.
*
* Plugins can add new composition providers to change the loading
* behavior for certain domain objects.
*
* @method addProvider
* @param {module:openmct.CompositionProvider} provider the provider to add
* @returns {module:openmct.CompositionCollection}
* @memberof module:openmct.CompositionAPI#
*/
composition.addProvider = function (provider) {
PROVIDER_REGISTRY.unshift(provider);
};