PDA

View Full Version : Stores and singletons



delp
4 Dec 2013, 7:23 AM
How do you implement a store to be a singleton?

In architect my store has a property checkbox that adds the property

singleton: true,

If I add that then reload the application it fails to load (I can give more details if required about error)

Uncaught TypeError: object is not a function VM5238:3
(anonymous function) VM5238:3
Ext.ClassManager.instantiate ext-all-debug.js:5485
(anonymous function) ext-all-debug.js:2109
Ext.define.getStore

If I then remove that property it loads fine, but where I use Ext.getStore("MyStore") then the stores that are returned contain different data depending on where I'm using the store.

Also there does not appear to be any documentation about the singleton property in the docs. If I look at Ext.data.Store there is no singleton.

Kevin Jackson
6 Dec 2013, 2:13 PM
It appears this is an Architect question. Can you tell me the Version Number you are using so I can forward to the appropriate people?

delp
6 Dec 2013, 3:24 PM
It's Architect version 2.2.2

I did find out that by calling the getInsertStoreNameHereStore() returns the store for the controller. So no need to to use the Ext.StoreMgr or Ext.StoreManager or Ext.Create(StoreClassName).

Also found that when using the store that is generated by the controller, it uses the Class name and not the storeId that you give it as part of the properties.

For an unknown reason at the moment the automatic getter wasn't available the first time I went to check the store which is why I started to use Ext.getStore() and the above. I was going to try an answer my question when I figured out why it wasn't working - but it is working now :)

And I'm presuming that you just shouldn't be able to make the store a singleton in a controller (hence the error) as it is already one when you use the generated one.