Download 1.5.x - Docs

Transcript
qooxdoo Documentation, Release 1.5.1
// ...
construct : function(min, value, max) {
// ...
if (value !== undefined) {
this.setValue(value);
} else {
this.initValue();
}
// ...
_applyValue: function(value, old)
// ...
this._updateButtons();
// ...
The example shows the constructor and the apply of the value property. The problem begins in this case with the
constructor parameter named value, which is optional. So we have three cases to consider.
1. The value argument is undefined: The initValue method is called, which invokes the apply function for the
property with the init value as value.
2. A value is given different as the init value: So the value is not undefined and the setter for the value property
will be called, which invokes the apply function.
3. A value is given and its exactly the init value: In this case, the setter will be called with the init value. The apply
method is called and invokes the _updateButtons method. This method checks the given value and enables
/ disabled the buttons for increasing / decreasing the spinner. So it is necessary that the apply method is at least
called once that the buttons have the proper states.
The problem with a possible change of this behavior is obvious. In the third case, the apply method is not called and
the buttons enabled states could be wrong without throwing an error. And they are only wrong, if the value is exactly
the init value and one of the minimum or maxiumum values is the same. Because only in that scenario, one of the
buttons need to be disabled.
When can it be changed?
Currently we don’t plan to change it because it can have some hard to track side effects as seen in the example above
and we don’t have any deprecation strategy. Maybe it can be change on a major version like 2.0 but currently there are
no plans to do so.
3.2.4 Property features summarized
Note: The chapter gives you an compact but extensive overview of the features offered by qooxdoo’s property system.
Please refer to Properties in more detail for an explanation of how to define and use properties.
Value checks
• Built-in types for most common things
• Runtime checks (development version only)
• Instance checks by simply define the classname of the class to check for (always use an instanceof operation - a
real classname is not available anymore)
• Custom check method by simply attaching a function to the declaration
96
Chapter 3. Core Framework