mirror of
https://github.com/nasa/openmct.git
synced 2025-06-14 21:28:12 +00:00
[Example] Use implementations in examples
Use implementations of custom extensions in examples. WTD-518.
This commit is contained in:
@ -8,9 +8,11 @@ define(
|
|||||||
function () {
|
function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var HAS_EXTENSIONS = "A directive loaded these example extensions.",
|
var HAS_EXTENSIONS = "A directive loaded these message from " +
|
||||||
|
"example extensions.",
|
||||||
NO_EXTENSIONS = "A directive tried to load example extensions," +
|
NO_EXTENSIONS = "A directive tried to load example extensions," +
|
||||||
" but found none.";
|
" but found none.",
|
||||||
|
MESSAGE = "I heard this from my partial constructor.";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -22,8 +24,14 @@ define(
|
|||||||
HAS_EXTENSIONS : NO_EXTENSIONS;
|
HAS_EXTENSIONS : NO_EXTENSIONS;
|
||||||
|
|
||||||
template += "<ul>"
|
template += "<ul>"
|
||||||
examples.forEach(function (e) {
|
examples.forEach(function (E) {
|
||||||
template += "<li>" + e.text + "</li>";
|
template += "<li>";
|
||||||
|
if (typeof E === 'function') {
|
||||||
|
template += (new E(MESSAGE)).getText();
|
||||||
|
} else {
|
||||||
|
template += E.text;
|
||||||
|
}
|
||||||
|
template += "</li>";
|
||||||
});
|
});
|
||||||
template += "</ul>";
|
template += "</ul>";
|
||||||
|
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
"examples": [
|
"examples": [
|
||||||
{
|
{
|
||||||
"text": "I came from example/extensions"
|
"text": "I came from example/extensions"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"implementation": "SomeExample.js",
|
||||||
|
"depends": [ "exampleService" ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
31
example/extensions/src/SomeExample.js
Normal file
31
example/extensions/src/SomeExample.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*global define,Promise*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module defining SomeExample. Created by vwoeltje on 11/5/14.
|
||||||
|
*/
|
||||||
|
define(
|
||||||
|
[],
|
||||||
|
function () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function SomeExample(exampleService, message) {
|
||||||
|
return {
|
||||||
|
getText: function () {
|
||||||
|
return [
|
||||||
|
'"',
|
||||||
|
exampleService.getMessage(),
|
||||||
|
'" and "',
|
||||||
|
message,
|
||||||
|
'"'
|
||||||
|
].join("");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return SomeExample;
|
||||||
|
}
|
||||||
|
);
|
Reference in New Issue
Block a user