-
Notifications
You must be signed in to change notification settings - Fork 106
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
Ext.applyIf() doen't work for empty class members #259
Comments
I have a hard time to understand what you are actually suggesting. Can you possible give an example (preferable with some before/after code). Thanks. |
I didn't want to close this, sorry. |
Consider the following example:
The parent class has a member "layers" that is initially set to null. ApplyIf (as being the preferred way of merging config params by Sencha) will not work unless i manually override the layers member variable with undefined. |
but I also see null values in Sencha's own codebase, e.g. value in Do you have a reference that states that applyIf is the preferred way by Sencha also for Ext 4? |
Also can you explain to me what the issue would be with using Ext.apply in your class? What could be unwanted side effects? |
@bartvde Interesting that you found a null param in an extJS-class. There seems to be a different policy with cfg-params vs. private class members. |
Okay I think you have persuaded me @hutzelknecht I would support a PR to implement this @marcjansen what about you? |
To be honest I still do not see any problem. When you subclass something and then set new hardcoded values in What would be needed to fix the issue? Switch from initializing with I do not want to introduce s.th. that makes us need to call the next version 2.1.0 if it is not absolutely necessary. |
The effect of first setting // ...
initComponent: function(){
// ... use applyIf for you usual overwrites
this.layers = this.createLayers();
this.callParent();
} |
Btw is anybody actually using GeoExt with Sencha Architect? If so, that could make this issue more real? |
We are using architect but only for scaffolding and click dummies. |
This is nothing really urgent. For me and my collegues this is now a known issue where we will use a workaround. Could be that only experienced extjs developers know of the benefits of using applyIf. Therefore developers new to the framework don't run into this kind of issue. |
you use applyIf to apply defaults without loosing the ability to have it configured
the applyIf version has the advantage that you don't have to repeat the variable twice |
Ext.applyIf checks for "undefined" values by typed comparison and therefore ignores "null" valued members.
When subclassing GeoExt classes the applyIf-method proved useful in the past. My suggestion would be to exchange all empty member declarations. Any possible negative side effects to this suggestion?
see: http://docs.sencha.com/extjs/4.2.1/source/Ext.html#Ext-method-applyIf
The text was updated successfully, but these errors were encountered: