mirror of
https://github.com/nasa/openmct.git
synced 2025-06-14 05:08:15 +00:00
[Framework] Begin adding registration phase
Begin implementation registration phase of framework layer initialization process. This phase is responsible for registering resolved extensions with Angular, in a manner than individual extensions can later request dependencies from. WTD-518.
This commit is contained in:
65
platform/framework/src/FrameworkInitializer.js
Normal file
65
platform/framework/src/FrameworkInitializer.js
Normal file
@ -0,0 +1,65 @@
|
||||
/*global define,Promise*/
|
||||
|
||||
/**
|
||||
* Module defining FrameworkInitializer. Created by vwoeltje on 11/3/14.
|
||||
*/
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
*
|
||||
* @constructor
|
||||
* @param {BundleLoader} loader
|
||||
* @param {ExtensionResolver} resolver
|
||||
* @param {ExtensionRegistrar} registrar
|
||||
* @param {ApplicationBootstrapper} bootstrapper
|
||||
*/
|
||||
function FrameworkInitializer(loader, resolver, registrar, bootstrapper) {
|
||||
|
||||
function registerExtensions(resolvedExtensions) {
|
||||
Object.keys(resolvedExtensions).forEach(function (category) {
|
||||
registrar.registerExtensions(
|
||||
category,
|
||||
resolvedExtensions[category]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bundles
|
||||
* @returns {Object.<string, object[]>} an object mapping
|
||||
*/
|
||||
function resolveExtensions(bundles) {
|
||||
var resolvedExtensions = {};
|
||||
|
||||
|
||||
function resolveExtensionsForBundle(bundle) {
|
||||
|
||||
}
|
||||
|
||||
return Promises.all(bundles.map(resolveExtensionsForBundle)).then(function () {
|
||||
return resolvedExtensions;
|
||||
});
|
||||
}
|
||||
|
||||
function loadBundles(bundleList) {
|
||||
return loader.loadBundles(bundleList);
|
||||
}
|
||||
|
||||
return {
|
||||
runApplication: function (bundleList) {
|
||||
return loadBundles()
|
||||
.then(resolveExtensions)
|
||||
.then(registerExtensions)
|
||||
.then(bootstrapApplication);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
return FrameworkInitializer;
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user