Shyru
17 Jan 2012, 7:07 AM
We have an override for Ext.data.AbstractStore that adds plugin-support for Stores. To minimize needed changes between ExtJS updates I coded it with using borrow which borrows the plugin initialization logic from Ext.AbstractComponent like this:
/*
* Add plugin support for stores.
* This is done by borrowing some methods from Ext.AbstractComponent and modifying the constructor of Ext.data.AbstractStore
*/
//borrow plugin methods from AbstractComponent
Ext.data.AbstractStore.borrow(Ext.AbstractComponent,['plugins','constructPlugins','getPlugin','initPlugin','constructPlugin']);
//add plugin initialisation code at the end of the constructor of Ext.data.AbstractStore:
Ext.override(Ext.data.AbstractStore,{
constructor:Ext.Function.createSequence(Ext.data.AbstractStore.prototype.constructor,function(){
var i,len;
if (this.plugins)
{
console.log("Plugins are:",this.plugins);
this.plugins = [].concat(this.plugins);
this.constructPlugins();
for (i = 0, len = this.plugins.length; i < len; i++)
{
this.plugins[i] = this.initPlugin(this.plugins[i]);
}
}
})
});
In ExtJs 4.0.7 this was working fine, but with ExtJS 4.1Beta1 this bails out in constructPlugin() where plugin is null. I tried to debug it, but debugging borrowed methods is kinda fun. Perhaps its a scope problem. I noticed that Ext.Base.borrow changed a lot between 4.0.7 and 4.1Beta1. So either this introduced a bug or I'm doing something wrong.
If needed I would be willing to provide a complete testcase.
/*
* Add plugin support for stores.
* This is done by borrowing some methods from Ext.AbstractComponent and modifying the constructor of Ext.data.AbstractStore
*/
//borrow plugin methods from AbstractComponent
Ext.data.AbstractStore.borrow(Ext.AbstractComponent,['plugins','constructPlugins','getPlugin','initPlugin','constructPlugin']);
//add plugin initialisation code at the end of the constructor of Ext.data.AbstractStore:
Ext.override(Ext.data.AbstractStore,{
constructor:Ext.Function.createSequence(Ext.data.AbstractStore.prototype.constructor,function(){
var i,len;
if (this.plugins)
{
console.log("Plugins are:",this.plugins);
this.plugins = [].concat(this.plugins);
this.constructPlugins();
for (i = 0, len = this.plugins.length; i < len; i++)
{
this.plugins[i] = this.initPlugin(this.plugins[i]);
}
}
})
});
In ExtJs 4.0.7 this was working fine, but with ExtJS 4.1Beta1 this bails out in constructPlugin() where plugin is null. I tried to debug it, but debugging borrowed methods is kinda fun. Perhaps its a scope problem. I noticed that Ext.Base.borrow changed a lot between 4.0.7 and 4.1Beta1. So either this introduced a bug or I'm doing something wrong.
If needed I would be willing to provide a complete testcase.