I want to create a singleton object in Ext JS 4.
Here is my code:
Ext.define('AM.model.Test', { extend : 'Ext.util.Observable', singleton : true, foo : function() { console.log('log 1'); }, constructor : function() { } });
I call it with
AM.model.Test.foo();
Everything works fine while I set the definition in app.js. When I try to move this definition to "app \ model \ Test.js", I get this error:
AM.model.Test is undefined [Break On This Error]
AM.model.Test.foo();
What is wrong with my code?
source share