Skip to content

Instantly share code, notes, and snippets.

@EyePulp
Created August 21, 2013 00:27
Show Gist options
  • Save EyePulp/6289059 to your computer and use it in GitHub Desktop.
Save EyePulp/6289059 to your computer and use it in GitHub Desktop.
require.js module example
require(['some_module'], // import your module
function(mm){ // give it a local reference
var MyInstance = new mm({'yo':'ho ho'}); // instantiate it with a value
MyInstance.bar(); // run some functions off of it
}
);
define(['jquery','knockout','lodash'], // define whatever imported modules you need for your module
function($,ko,_) { // assign the imported modules to variable references
return function(foo){ // return the module you're creating
var self = this;
self.foo = foo;
self.bar = function(){
console.log(self.foo);
};
};
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment