Skip to content

Instantly share code, notes, and snippets.

@jshirley
Created July 20, 2012 14:14
Show Gist options
  • Select an option

  • Save jshirley/3150949 to your computer and use it in GitHub Desktop.

Select an option

Save jshirley/3150949 to your computer and use it in GitHub Desktop.
// When you define your module, you specify a function to run when it's being added in.
// This includes a `Y` object:
YUI.add('myModule', function(Y) {
Y.Foo = function() { alert("Foo"); };
});
// When you *use* your module, you declare a similar function that gets a `Y` object passed in.
YUI().use('myModule', function(Y) {
Y.Foo = function() { alert("Bar"); };
});
YUI().use('myModule', function(Y) {
Y.Foo(); // Will alert Foo, since you didn't modify anything in this namespace
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment