Skip to content

Instantly share code, notes, and snippets.

@boombang
Created April 6, 2019 16:56
Show Gist options
  • Save boombang/9f256b47f3c6a4762dc20a144ba45f5c to your computer and use it in GitHub Desktop.
Save boombang/9f256b47f3c6a4762dc20a144ba45f5c to your computer and use it in GitHub Desktop.
//my-module.js
define([], function() {
var privateVar = "Ben Cherry";
var publicVar = "Hey there!";
function privateFunction() {
console.log( "Name:" + privateVar );
}
function publicSetName( strName ) {
privateVar = strName;
}
function publicGetName() {
privateFunction();
}
return {
setName: publicSetName,
greeting: publicVar,
getName: publicGetName
}
});
// index.js
define(['my-module'], function (myModule) {
myModule.setName( "Paul Kinlan" );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment