Skip to content

Instantly share code, notes, and snippets.

@telekosmos
Created April 15, 2013 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save telekosmos/5388045 to your computer and use it in GitHub Desktop.
Save telekosmos/5388045 to your computer and use it in GitHub Desktop.
Private methods in a ExtJs4 class, using kind of Module Pattern. Do not abuse of this!!!
Ext.define('PrivateTest', (function () {
var privTest = function (param) {
return 'privTest method!!!';
};
var privTest2 = function (param) {
return 'another privTest2('+param+') method!!!';
};
return {
constructor: function () {
this.callParent(arguments);
},
chooseMethod: function (what) {
switch (what) {
case 1: return privTest;
case 2: return privTest2;
default: return privTest;
}
}
} // EO return
})()
);
var myTest = Ext.create('PrivateTest');
var res1 = myTest.chooseMethod(1)();
console.log('a ver??? '+res1);
var res2 = myTest.chooseMethod(2)('secondary');
console.log('with a param: '+res2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment