2012-05-09 61 views
5

我曾經使用商店的autoDestroy屬性。清理內存資源。但我無法再在API中找到它。如何在ExtJS 4.1中銷燬商店?

我發現EXTJSIV-4844 - Ext.data.Store autoDestroy config is missing列在4.1 RC1 Bug Fixes(儘管我無法在任何地方找到該錯誤的線程)。

現在在RC3中,該配置從API中消失了,並且它不再在源文件中。

我已使用Ext.destroy作爲視圖,但從未用於商店。 API的描述方式方法here聽起來像這樣:「這種方法是爲小部件設計的,但它會接受任何對象並查看它可以做什麼」。換句話說,不是很明確。

有沒有人碰巧知道Ext.destroy是否適用於商店並將其從內存中移除?或者推薦的方法是什麼?

回答

8

Ext.data.Store.destroyStore看起來像您想要使用的方法。它由於某種原因是私人的(它甚至沒有在文檔中顯示,如果show private被選中),但它看起來像3.4的公共Store.destroy http://docs.sencha.com/ext-js/3-4/#!/api/Ext.data.Store-method-destroy相同的功能。在4.x中有一個Store.destroy方法,但這是完全不同的,不應該被用來從內存中銷燬商店。這裏是來自http://docs.sencha.com/ext-js/4-1/source/AbstractStore.html#Ext-data-AbstractStore

// private 
destroyStore: function() { 
    var me = this; 

    if (!me.isDestroyed) { 
     if (me.storeId) { 
      Ext.data.StoreManager.unregister(me); 
     } 
     me.clearData(); 
     me.data = me.tree = me.sorters = me.filters = me.groupers = null; 
     if (me.reader) { 
      me.reader.destroyReader(); 
     } 
     me.proxy = me.reader = me.writer = null; 
     me.clearListeners(); 
     me.isDestroyed = true; 

     if (me.implicitModel) { 
      Ext.destroy(me.model); 
     } else { 
      me.model = null; 
     } 
    } 
}, 
+0

看起來不錯,謝謝你發現 – Geronimo