mirror of
https://github.com/nasa/openmct.git
synced 2024-12-24 07:16:39 +00:00
[Framework] Simplify custom registration
Handle the iteration over extensions which have a custom registration mechanism (directives, services) at the same level that general registration is handled. WTD-518.
This commit is contained in:
parent
00de789f5e
commit
d8eb72621b
@ -45,9 +45,7 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
services: function (extensions) {
|
services: registerExtension;
|
||||||
return extensions.map(registerExtension);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ define(
|
|||||||
// Track which extension categories have already been registered.
|
// Track which extension categories have already been registered.
|
||||||
// Exceptions will be thrown if the same extension category is
|
// Exceptions will be thrown if the same extension category is
|
||||||
// registered twice.
|
// registered twice.
|
||||||
var registeredCategories = {},
|
var registeredCategories = {};
|
||||||
|
|
||||||
function identify(category, extension, index) {
|
function identify(category, extension, index) {
|
||||||
var name = extension.key ?
|
var name = extension.key ?
|
||||||
@ -68,11 +68,16 @@ define(
|
|||||||
category,
|
category,
|
||||||
" more than once. Ignoring all but first set."
|
" more than once. Ignoring all but first set."
|
||||||
].join(""));
|
].join(""));
|
||||||
} else if (customRegistrars[category]) {
|
} else {
|
||||||
return customRegistrars[category](extensions);
|
// Register all extensions. Use custom registration
|
||||||
|
// code for services, directives, etc; otherwise,
|
||||||
|
// just register them under generic names.
|
||||||
|
if (customRegistrars[category]) {
|
||||||
|
extensions.forEach(customRegistrars[category]);
|
||||||
} else {
|
} else {
|
||||||
extensions.forEach(registerExtension);
|
extensions.forEach(registerExtension);
|
||||||
registerExtensionArraysForCategory(category, names);
|
registerExtensionArraysForCategory(category, names);
|
||||||
|
}
|
||||||
registeredCategories[category] = true;
|
registeredCategories[category] = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user