From 851d0f0d6374a5622a7ad2cada5632f29b1ef509 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 7 Sep 2016 08:09:37 -0700 Subject: [PATCH] [API] Clean up Composition API --- src/MCT.js | 19 ++++++++++++++-- src/api/composition/CompositionAPI.js | 31 ++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/MCT.js b/src/MCT.js index a844f47359..dfbf83c6a0 100644 --- a/src/MCT.js +++ b/src/MCT.js @@ -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) { diff --git a/src/api/composition/CompositionAPI.js b/src/api/composition/CompositionAPI.js index e41b534668..10090c92de 100644 --- a/src/api/composition/CompositionAPI.js +++ b/src/api/composition/CompositionAPI.js @@ -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); };