Skip to content

Instantly share code, notes, and snippets.

@Samjin
Created May 3, 2016 18:01
Show Gist options
  • Save Samjin/4bea51672f26682b22c8f501f78c3be9 to your computer and use it in GitHub Desktop.
Save Samjin/4bea51672f26682b22c8f501f78c3be9 to your computer and use it in GitHub Desktop.
Facade simple exmaple
var module = (function() {
var _private = {
i:5,
get : function() {
console.log( "current value:" + this.i);
},
set : function( val ) {
this.i = val;
},
run : function() {
console.log( "running" );
},
jump: function(){
console.log( "jumping" );
}
};
return {
facade : function( args ) {
_private.set(args.val);
_private.get();
if ( args.run ) {
_private.run();
}
}
};
}());
// Outputs: "running", 10
module.facade( {run: true, val:10} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment