Skip to content

Instantly share code, notes, and snippets.

@sebastianfrelle
Created October 9, 2016 18:15
Show Gist options
  • Save sebastianfrelle/25f03820b1a38fda927e92e953272b0b to your computer and use it in GitHub Desktop.
Save sebastianfrelle/25f03820b1a38fda927e92e953272b0b to your computer and use it in GitHub Desktop.
var MainModule = (function() {
var alertMsg = "Der er fejl izi game izi lyfe";
function privateGetAlertMsg() {
return alertMsg;
}
function privateSetAlertMsg(newAlertMsg) {
alertMsg = newAlertMsg;
}
return {
getAlertMsg: privateGetAlertMsg,
setAlertMsg: privateSetAlertMsg
};
}());
// "Inject" det module, man vil bruge, som en parameter til en immediately-invoked functional expression.
// Fungerer lidt ligesom injection i Angular.
var PeopleModule = (function(superModule) {
// Her kan superModule (peger på MainModule) bruges
function privateDoSomething() {
alert(superModule.getAlertMsg());
}
return {
publicDoSomething: privateDoSomething
};
}(MainModule));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment