From 8e31b2b6e040ec695ae7db4ce0f5292deb681fb5 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 4 Nov 2014 13:00:12 -0800 Subject: [PATCH] [Framework] Add bootstrapper Add an application bootstrapper, responsible for handling the Angular bootstrapping phase of framework layer initialization. WTD-518. --- .../framework/src/ApplicationBootstrapper.js | 40 +++++++++++++++++++ platform/framework/src/ExtensionRegistrar.js | 4 ++ .../framework/src/FrameworkInitializer.js | 2 +- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 platform/framework/src/ApplicationBootstrapper.js diff --git a/platform/framework/src/ApplicationBootstrapper.js b/platform/framework/src/ApplicationBootstrapper.js new file mode 100644 index 0000000000..10d3f27c80 --- /dev/null +++ b/platform/framework/src/ApplicationBootstrapper.js @@ -0,0 +1,40 @@ +/*global define,Promise*/ + +/** + * Module defining Bootstrapper. Created by vwoeltje on 11/4/14. + * + * The bootstrapper is responsible + */ +define( + [], + function () { + "use strict"; + + /** + * The application bootstrapper is responsible for issuing the + * bootstrap call to Angular. This would normally not be needed + * with an appropriately-placed ng-app directive, but the + * framework needs to wait until all extensions have been loaded + * and registered. + * + * @constructor + */ + function ApplicationBootstrapper(angular, document) { + return { + /** + * @method + * @memberof ApplicationBootstrapper# + * @param {angular.Module} app the Angular application to + * bootstrap + */ + bootstrap: function (app) { + angular.element(document).ready(function () { + angular.bootstrap(document, [app.name]); + }); + } + }; + } + + return ApplicationBootstrapper; + } +); \ No newline at end of file diff --git a/platform/framework/src/ExtensionRegistrar.js b/platform/framework/src/ExtensionRegistrar.js index 7ee886314c..1ab0e11630 100644 --- a/platform/framework/src/ExtensionRegistrar.js +++ b/platform/framework/src/ExtensionRegistrar.js @@ -94,6 +94,10 @@ define( extensionGroup[category] ); }); + + // Return the application to which these extensions + // have been registered + return app; } customRegistrars = customRegistrars || {}; diff --git a/platform/framework/src/FrameworkInitializer.js b/platform/framework/src/FrameworkInitializer.js index e3fae0ef87..75e88abee1 100644 --- a/platform/framework/src/FrameworkInitializer.js +++ b/platform/framework/src/FrameworkInitializer.js @@ -45,7 +45,7 @@ define( return loader.loadBundles(bundleList) .then(resolver.resolveBundles) .then(registrar.registerExtensions) - .then(bootstrapper.bootstrapApplication); + .then(bootstrapper.bootstrap); }