Skip to content

Instantly share code, notes, and snippets.

@morganrallen
Created Jul 12, 2010
Embed
What would you like to do?
(function(global) {
var config = false,
modules = [];
// setup single public namespace
var skel = global.skel = {
init: function(c) {
// put initial config in the public scope
config = c;
for(var i = 0; i < modules.length; i++) {
modules[i].run(config);
}
},
register: function(module) {
if(!module.run) {
throw new Error("Modules must provide at minimal a run() function");
};
modules.push(module);
if(module.register) {
modules.register(config);
};
}
}
})(this);
skel.init();
(function(skel) {
skel.register({
name: "skeleton",
run: function(config) {
// do some stuff
var x = 1;
return x;
}
});
})(skel);
@morganrallen

This comment has been minimized.

Copy link
Owner Author

@morganrallen morganrallen commented Jul 12, 2010

In this situation, run.js would be the last in the build.xml concatanation and gets this started. Modules register themselves if they need to do anything at runtime. init() then runs each of the modules after initing itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment