_overwriteData(data, type) {
            if (this._destroyed) {
                //we have received the ownership of the data, destroy it too since we are destroyed
                $.converter.destroy(data, type);
                return $.Promise.resolve();
            }
            if (this.loaded) {
                // No-op if attempt to replace with the same object
                if (this._data === data && this._type === type) {
                    return this._promise;
                }
                $.converter.destroy(this._data, this._type);
                this._type = type;
                this._data = data;
                this._promise = $.Promise.resolve(data);
                const internal = this[DRAWER_INTERNAL_CACHE];
                if (internal) {
                    for (let iCache in internal) {
                        internal[iCache].setDataAs(data, type);
                    }
                }
                this._triggerNeedsDraw();
                return this._promise;
            }
            return this._promise.then(() => {
                // No-op if attempt to replace with the same object
                if (this._data === data && this._type === type) {
                    return this._data;
                }
                $.converter.destroy(this._data, this._type);
                this._type = type;
                this._data = data;
                this._promise = $.Promise.resolve(data);
                const internal = this[DRAWER_INTERNAL_CACHE];
                if (internal) {
                    for (let iCache in internal) {
                        internal[iCache].setDataAs(data, type);
                    }
                }
                this._triggerNeedsDraw();
                return this._data;
            });
        }
Safely overwrite the cache data and return the old data
@private