Skip to content

Instantly share code, notes, and snippets.

@YozhEzhi
Last active September 16, 2015 11:51
Show Gist options
  • Save YozhEzhi/7c3dcd14a8c98ba8ec22 to your computer and use it in GitHub Desktop.
Save YozhEzhi/7c3dcd14a8c98ba8ec22 to your computer and use it in GitHub Desktop.
JS pattern Facade
var module = (function() {
var _private = {
i: 5,
get: function() {
console.log('Текущее значение:' + this.i);
},
set: function(val) {
this.i = val;
},
run: function() {
console.log('Процесс запущен');
},
jump: function() {
console.log('Резкое изменение');
}
};
return {
facade: function(args) {
_private.set(args.val);
_private.get();
if (args.run) {
_private.run();
}
}
};
}());
module.facade({
run: true,
val: 10
}); // Текущее значение: 10, процесс запущен;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment