-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[0.8]: observer callbacks changed parameter ordering #1363
Comments
Since the order in attributeChangedCallback is oldValue, newValue, it would On Thu, Apr 2, 2015 at 1:58 PM, Eric Bidelman [email protected]
|
+1 also good point. |
FWIW, |
I haven't seen many people use Changed handlers as callbacks. 90% of the time you just use |
Would prefer all official elements going forward to use: fooChanged: function(foo) {
} style. But the lack of parallelism wrt |
Why do you prefer to use the parameter instead of |
It's more compact and less stateful. Parameterization is generally good factoring. |
if it is implicit that <script>
FooChanges = {
properties: {
foo:{
type:String,
value:"orderMatters!",
observer:"fooChanged"
}
},
fooChanged:function(){
this._biasTowardsTheNew(this.foo);
},
_biasTowardsTheNew:function(foo){
console.log("Communicating about how to communicate change is difficult");
}
}
</script> Perhaps exposing an additional configuration parameter when annotating a property observer might be useful to appease single arg new bias |
I think Scott's point was that if the order is new, old, then you can use a single-argument observer, too. That is, in your example, |
@arthurevans thank you for emphasizing this and have no argument for those who have that preference. I was addressing the parameter |
A function that does not include |
TYVM! I absolutely agree with stateless function definition and ease of reuse! Just reiterating, the polymer/behavior declaration has no additional state after the observer callback using Additional decoupling in a |
0.5:
disabledChanged: function(oldValue, newValue) {
0.8:
disabledChanged: function(newValue, oldValue) {
It's a very subtle change and easy to miss...adds "one more thing to do" when porting 0.5 code :(
Was there a reason to change the ordering?
The text was updated successfully, but these errors were encountered: