-
18 Nov 2011 1:39 AM #1
Answered: [PR2] delete config.listeners - purposeful behavior?
Answered: [PR2] delete config.listeners - purposeful behavior?
I have scenario in my app that allows me to open a detailed view multiple times during a itemdoubletap listener of a list. The event shows another view, which have a 'close button' that allows user to get back to list.
My problem is coused of that I am moving my application from Sencha Touch 1.0 and I have listeners declared in list configuration. The problem what I have observed in PR2 (in PR1 everything was working fine) is that my listeners declared in list configuration are deleted after first assignment to list/view.
The code is: (in debug version):
Is it a purposeful behavior and a good behavior to deleting that config? What should I do to avoid further problems with something like this? Couse now, of course, I could comment that lines and problem dissapear. But it is not a solution in case to Yours further releases.Code:constructor: function(config) { if (config) { if ('listeners' in config) { this.setListeners(config.listeners); delete config.listeners; } if ('bubbleEvents' in config) { this.setBubbleEvents(config.bubbleEvents); delete config.bubbleEvents; } } return this; }
Is is possible to check original configuration for listeners in component and restoring them if nothing change them during application lifecycle?
-
Best Answer Posted by Jacky Nguyen
In PR2 we made the constructor of Observable mixin to be executed before the constructor of the target class to ensure all given listeners are added before any other config item is initialized. Deleting config.listeners after it's already been processed is merely a performance optimization so that it doesn't get double-processed again when the target class invoke initConfig().
We are aware of the issue you're encountering as a consequence of this change, when the same config object reference is reused again in multiple instantiation. A temporary workaround is to not use the same config reference while we're looking into a more permanent solution.
-
18 Nov 2011 3:15 AM #2Sencha - Sencha Touch Dev Team
- Join Date
- Jul 2009
- Location
- Palo Alto, California
- Posts
- 469
- Vote Rating
- 9
- Answers
- 24
In PR2 we made the constructor of Observable mixin to be executed before the constructor of the target class to ensure all given listeners are added before any other config item is initialized. Deleting config.listeners after it's already been processed is merely a performance optimization so that it doesn't get double-processed again when the target class invoke initConfig().
We are aware of the issue you're encountering as a consequence of this change, when the same config object reference is reused again in multiple instantiation. A temporary workaround is to not use the same config reference while we're looking into a more permanent solution.Sencha Touch Lead Architect


Reply With Quote