-
1 Jun 2012 5:25 AM #1
destroying associated-store
destroying associated-store
Hi,
How can I completely destroy the associated store?
My solution is:
Does anybody know the best solution for this?Code:user.posts().destroyStore(); delete user.postsStore;
Thanks
-
1 Jun 2012 9:52 AM #2
The private function destroyStore() in 4.x should do what you need. This basically the same as store.destroy() in 3.4.
As long as you remove all reference to your store (StoreManager, components) then it should be picked up the garbage collector.
Regards,
Scott.
-
1 Jun 2012 2:10 PM #3
The private function destroyStore() in 4.x should do what you need --- unfortunately, no

in my case after user.posts().destroyStore(), user.postsStore still exists
-
1 Jun 2012 2:25 PM #4
I am not sure I understand your call...
mystore.destroyStore() does not work?
Scott.
-
1 Jun 2012 11:22 PM #5
Ok, I'll try to make things clear.
now, type in your console these lines:Code:Ext.define("Website", { extend: "Ext.data.Model", idProperty: "websiteId", fields: [ 'websiteId', 'website', 'active' ], proxy: { type: 'ajax', reader: { type: "json", root: "items" } } }); Ext.define("User", { extend: "Ext.data.Model", idProperty: "userId", fields: [ 'firstName', 'lastName' ], associations: [{ type: "hasMany", name: "websites", model: "Website", primaryKey: "userId", foreignKey: "userId", storeConfig: { storeId: "websites" } }], proxy: { type: "memory", reader: { root: "items", type: "json" } } }); Ext.define("Users", { extend: "Ext.data.Store", model: "User", data: { items: [{ firstName: "F1", lastName: "L1", userId: 1, websites: [{ websiteId: 1, userId: 1, website: "http://facebook.com/rsqw", active: 1 }, { websiteId: 2, userId: 1, website: "http://twitter.com/rsqw", active: 1 }] }] }, autoLoad: true });
store = new Users;
store.first().websites().destroyStore();
so, as far as I understand, websites-store should be picked up the garbage collector, Yes?
-
2 Jun 2012 12:25 PM #6
No. Calling destroyStore will just tear down the internals of the store. It can't remove all references to it to make it eligible for garbage collection. If the only reference to the store is from the owner record then it will become eligible for garbage collection at the same time as the record.
Perhaps a better question is why are you trying to destroy an associated store? There are some cases where it makes sense but I'd be curious to know what your motivation is.


Reply With Quote