23 Jan 2013 9:40 AM #1
Unanswered: Touch 2.1 Constructor change?
I've been attempting to upgrade from 2.0 to 2.1 and am running into quite a few problems, mostly they are working out with small changes. One seemingly strange and dangerous change though is the new way constructors are handled.
It seems a constructor can now return a value instead of just finish instantiating the object that is being constructed. Just wondering what the best way would be to handle extending and overriding classes now?
I.E. used to do this.
Now, since the parent constructor may return a value that is not "this" we have to do something like this I think.
config = this.doSomePreProcessing();
var newThis = this.callParent(arguments) || this;
I don't actually think this will work in the end though since newThis could be a completely different thing, and wouldn't contain any of the extension properties. Touch Grid actually uses this "feature" to return a List implementation instead of a dataview implementation so our extension class isn't used.
Anyway, thought this should be documented somewhere, and I couldn't find it.
25 Jan 2013 6:37 AM #2
- Join Date
- Mar 2007
- Gainesville, FL
- Vote Rating
Touch grid does it and logs out that you shouldn't use it.Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Software Engineer
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services email@example.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!
When posting code, please use BBCode's CODE tags.
25 Jan 2013 7:52 AM #3
Yeah that was the second place we saw it and other than rewriting our extension entirely (it allows you to specify editor components that are always shown instead of having to click on them) it won't work with the new structure and winds up crashing because a List is returned instead of a Dataview and that List doesn't have any of the custom extension code of course.
The weird one is Model. It seems that model can return a cached version which for some reason didn't break in 2.0 but when we switched to 2.1 all of our models that have some kind of special constructor didn't work anymore and I had to use the mechanism above to get things working. I just noticed that the actual code is the same in 2.0 vs 2.1 so it's not really a change to the constructor, it's just that now it seems to matter in 2.1.