PDA

View Full Version : Question about Singletons in 4.0



rmoskal
13 Sep 2011, 11:43 AM
I've become accustomed to using Ext.define/Ext.create to manage and use my custom classes. I'm a little bit confused about using the singleton configuration. I see this in the docs:


Ext.define('Logger', { singleton: true, log: function(msg) { console.log(msg); }});Logger.log('Hello');If I do something like:


Ext.define('IH.core.Logger', { singleton: true, log: function(msg) { console.log(msg); }});and then call this like so from say a controller:var log = Ext.create('IH.core.Logger');
I get the dreaded "c is not a constructor" error.

Any pointers would be appreciated.

Thanks and regards,

Robert Moskal
Brooklyn USA

campersau1
13 Sep 2011, 11:57 AM
Singletons can't be instantiated!

Just use Logger.log("Hello World!");