I want to create a utility class which can have just one instance(singleton) therefore I have made a static method called getInstance() which would create a instance and return it to me.
I have posted below the code with a comment where i get and error and the the error description. Please let me know whats wrong with the code.
Any help appreciated.
Ext.define('MyApp.utility.EventManager',{
extend:'Ext.util.Observable',
instance: new MyApp.utility.EventManager(), //error as undefined EventManager property
statics:{
// instance: new MyApp.utility.EventManager(),
getInstance:function(){
if(!this.self.instance){
this.self.instance=Ext.create('MyApp.utility.EventManager');
return this.self.instance;
}
else{
return this.self.instance;
}
},
},
constructor:function(){
this.addEvents(
'success'
);
},
});