Skip to content

Instantly share code, notes, and snippets.

@mallim
Created September 10, 2013 01:13
Show Gist options
  • Save mallim/6503768 to your computer and use it in GitHub Desktop.
Save mallim/6503768 to your computer and use it in GitHub Desktop.
requirejs - Have a module that takes no dependencies. Example from http://tech.pro/blog/1561/five-helpful-tips-when-using-requirejs
//
// Have a module that takes no dependencies.
//
define({
someProp: "Oooh, how interesting!",
someMethod: function() {
// do interesting work
return compellingValue;
}
});
//
// Have a module that takes no dependencies,
// but you need to perform some sort of setup work (or store private state)
//
define(function() {
var secretValue = "seekret";
// do other initialization work here...
return {
someProp: "Oooh, how interesting!",
tellMeSecrets: function() {
// do interesting work
return secretValue;
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment