Skip to content

Instantly share code, notes, and snippets.

@Usse
Last active August 29, 2015 14:15
Show Gist options
  • Save Usse/93bbe325f79f1369b48b to your computer and use it in GitHub Desktop.
Save Usse/93bbe325f79f1369b48b to your computer and use it in GitHub Desktop.
Revealing module pattern
(function() {
var createWorker = function() {
var workCount = 0;
var task1 = function() {
workCount += 1;
console.log('Doing task2 :' + workCount);
}
var task2 = function() {
workCount += 1;
console.log('Doing task1 :' + workCount);
}
return {
job1: task1,
job2: task2
};
};
var worker = createWorker();
worker.job1();
worker.job2();
worker.job1();
worker.job2();
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment