public
Created

  • Download Gist
module.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
var app;
 
app = (function(){
var myPrivateVariable = "my private content";
var application = {
init: function(){
console.log(myPrivateVariable);
},
cache: function() {
// impl
},
bind: function() {
// impl
},
blabla: function(){
// ....
}
}
return application;
})();
 
app.init(); // > my private content
app.myPrivateVariable // > undefined

Thanks for sharing this, its awesome!

I really like this approach!
However, I'd rather improve the public API in this case. Why are the functions "cache" and "bind" public?

What do you think?

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.