Created
October 22, 2010 22:35
-
-
Save jboesch/641505 to your computer and use it in GitHub Desktop.
requireJS dependencies
This file contains hidden or 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
// Using http://requirejs.org/ | |
// loading scripts/misc/person.js | |
require(["misc/person"], function(person) { | |
person.loaded(function(){ | |
alert('dependencies loaded!'); | |
// dependencies loaded, now do something with person | |
}); | |
}); | |
// Inside scripts/misc/person.js | |
define(function(){ | |
var dependencies = [ | |
'helper/ear', // looking to scripts/helper/ear.js | |
'helper/nose', | |
'helper/eyes' | |
]; | |
return { | |
loaded: function(cb){ | |
require(dependencies, function(){ | |
cb.apply(this, arguments); | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah I'm just using the file location as the module name. I figured I'd just save some chars