-
-
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
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
// | |
// Have a module that takes no dependencies. | |
// | |
define({ | |
someProp: "Oooh, how interesting!", | |
someMethod: function() { | |
// do interesting work | |
return compellingValue; | |
} | |
}); |
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
// | |
// 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