- Suppose 'load' is triggered after 1 ms and the computer registers the first listener after 2 ms. Will someFunctionB be executed?
- If 'load' is triggered after 800 ms, and the computer registers the first listener after 2 ms and the second listener after 3 ms. Will someFunctionB be called for both indices?
Code:
SomeClass = Ext.Extend(SomeSuperClass,
initComponent: function () {
this['someStore'] = new Ext.data.Store({
proxy: x('y/z.asmx/s'),
reader:JSONReader([
{ name: 'g', type: 'string', mapping: 'g' },
]),
sortInfo: { field: 'g', direction: "ASC" }
});
this['someStore'].load(
{
params:
{
ID: this.config.id
}
});
for(var i = 0;i<2;i++){
this.someFunctionA(i);
}
}
someFunctionA: function(index){
this['someStore'].on("load", function() {this.someFunctionB(index);}, this);
}
someFunctionB: function(index){
var record = this['someStore'].getAt(index);
console.log(record);
}
}