-
Notifications
You must be signed in to change notification settings - Fork 13
Description
When using DeftJS in a project containing charts, you may experience an error like the following:
Uncaught TypeError: Cannot read property 'incr' of undefined
privates.doAddListener @ ext-all-debug.js:12630
addListener @ ext-all-debug.js:12384
Ext.Base.Ext.apply.createAlias.aliasOneMember.(anonymous function) @ ext-all-debug.js:7317
Ext.define.register @ deft-debug.js:771
(anonymous function) @ deft-debug.js:800
Ext.Function.ExtFunction.interceptAfter.object.(anonymous function) @ ext-all-debug.js:4638
Ext.define.constructor @ sencha-charts.js:1
constructor @ ext-all-debug.js:7657
...
According to my present investigation of the issue, it's related to the Ext.chart.series.Series object in ExtJS that apparently invokes Ext.ComponentManager.register before initialization of the Observable mixin and despite not being an actual Ext.Component instance.
Even though it's unclear whether this could be considered a bug in ExtJS (registering as component something that it is not) it's probably still unsafe for DeftJS to assume that the Observable mixin is initialized when Ext.ComponentManager.register is called.
Proposed solution would be to add the possibility to specify a flag on target components to avoid registration by Deft.event.LiveEventBus.register, more or less as follows:
Ext.Function.interceptAfter(Ext.ComponentManager, 'register', function(component) {
if(component.registerInLiveEventBus === false) return;
Deft.event.LiveEventBus.register(component);
});
Ext.Function.interceptAfter(Ext.ComponentManager, 'unregister', function(component) {
if(component.registerInLiveEventBus === false) return;
Deft.event.LiveEventBus.unregister(component);
});
Alternatively, modify the Deft.event.LiveEventBus.register method to both check for the availability of "on" and "un" methods, as well as correct initialization of the Observable mixin, for example by checking whether "hasListeners" is defined and only then attach the events listeners for 'added' and 'removed'.
Regards