I\'m currently developing a new web application.
This is the first time I\'m using requirejs with AMD modules.
It\'s not that easy to get used to tha
To answer your question as to how to provide an application wide event object, you can create an amd module called globalContext and instantiate it in the main.js.
Thereafter you can attach settings to the globalContext and use the global context to create subcomponents etc.
//main.js file
require([ "./global-context" ], function( GlobalContext) {
new GlobalContext();
});
In the global-context.js file we can then perform tasks such as loading child modules
define(["Boiler", "./settings", "./modules/modules"],
function (Boiler, settings, modules) {
var GlobalContext = function () {
//here we use a template javascript class called Boiler.Context
var globalContext = new Boiler.Context("GlobalModule");
//add settings to the context which can be obtained globally throughout the application
globalContext.addSettings(settings);
//here we load the sub modules of the global context
globalContext.loadChildModules(modules);
};
This is what we have implemented in BoilerplateJS, a reference architecture for large scale javascript product development.