Last active
August 29, 2015 14:22
-
-
Save jjsub/e55f9ddea284fb5b30d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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