Created
April 15, 2013 13:26
-
-
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!!!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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