Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to destroy stores in ExtJS 4.1?

I used to use a store's autoDestroy property. To clean out the memory resources. But I can't find this in the API anymore.

I found EXTJSIV-4844 - Ext.data.Store autoDestroy config is missing listed in the 4.1 RC1 Bug Fixes (though I can't find the thread for that bug anywhere).

Now in RC3 that config is gone from the API and it isn't in the source files anymore.

I've used Ext.destroy for views but never for stores. The way the API describes the Ext.destroy method here it sounds like: "This method is designed for widgets but it will accept any object and see what it can do". - In other words, not very definitive.

Does anyone happen to know if Ext.destroy works for stores and removes them from memory? Or what is the recommended way to go about this?

like image 867
egerardus Avatar asked May 09 '12 23:05

egerardus


1 Answers

Ext.data.Store.destroyStore looks like the method you want to use. It is private for some reason (it doesn't even show in the docs if show private is checked) but it looks like it has the same functionality of 3.4's public Store.destroy http://docs.sencha.com/ext-js/3-4/#!/api/Ext.data.Store-method-destroy. In 4.x there is a Store.destroy method but that is something completely different and should not be used to destroy the store from memory. Here is the source from 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;
        }
    }
},
like image 122
pllee Avatar answered Sep 20 '22 20:09

pllee