Skip to content

Instantly share code, notes, and snippets.

@hansmaad
Created March 26, 2014 08:39
Show Gist options
  • Save hansmaad/9778949 to your computer and use it in GitHub Desktop.
Save hansmaad/9778949 to your computer and use it in GitHub Desktop.
Template for Revealing Module Pattern with submodule
(function(module, undefined) {
var privateProb = "Private";
var privateFunc = function(prob) {
return prob + privateProb;
};
module.publicProb = "Hello Module";
module.publicFunc = function() {
return privateFunc(module.publicProb);
};
})(window.module = window.module || {});
(function(module, sub, undefined) {
var Custom = function(x, y) {
this.x = x;
this.y = y;
};
Custom.prototype.sum = function() {
return this.x + this.y ;
};
sub.custom = function(x, y) {
return new Custom(x, y);
};
})
(window.module = window.module || {},
window.module.sub = window.module.sub || {});
console.log(module.publicFunc());
var c = module.sub.custom(1, 2);
console.log(c.sum());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment