-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with ExtJS 5 and chart series component #9
Comments
Hi, Chris |
It's definitely a bug in Ext.chart.series.Series to register the component before it is initialized. That said, I have no idea if Sencha plans on fixing this (even though it's literally moving one line of code to the bottom of the constructor. So we may have to add guard logic to deal with it anyway. |
Since my needs are very simple, for the moment I put in place my own guard logic but it's a solution that cannot last for long of course. As a side note: Regards |
In Ext JS 4, ComponentManager.register() was public, so this is another case where Sencha has retroactively broken the API, since this method is now private in Ext JS 5. Why this is now private is somewhat confusing, since up until 5 it wasn't uncommon for folks to call this in custom components. That said, what probably really needs to happen is to determine if we even need the LiveEventBus any longer. My suspicion is we probably don't, since all the view listeners are now managed by the new Sencha event system. And I'm fairly sure the new system handles dynamic addition and removal of view components. |
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
The text was updated successfully, but these errors were encountered: