Skip to content

Instantly share code, notes, and snippets.

@jjsub
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjsub/e55f9ddea284fb5b30d0 to your computer and use it in GitHub Desktop.
Save jjsub/e55f9ddea284fb5b30d0 to your computer and use it in GitHub Desktop.
/* Modern Modules
Various module dependency loaders/managers essentially wrap up this pattern of module definition into a friendly API */
MyModules.define("bar", [], function() {
function hello(who) {
return "Let me introduce: " + who;
}
return {
hello: hello
};
});
MyModules.define("foo", ["bar"], function(bar) {
var hungry = "hippo";
function awesome() {
console.log(bar.hello(hungry).toUpperCase());
}
return {
awesome: awesome
};
});
var bar = MyModules.get("bar");
var foo = MyModules.get("foo");
console.log(
bar.hello("hippo")
); // Let me introduce: hippo
foo.awesome(); // LET ME INTRODUCE: HIPPO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment