I'm trying to upgrade my project to Ember 1.13, and I'm a bit confused about the behavior of new attrs of component, especially when I have to observe them.
For example, my test component observes bar which is a parameter passed from outside. I know in Ember's new Glimmer engine, the component rerenders once any of its attribute changes. What I can't figure out is that the observer will also be fired at that time if I observe attrs.bar (I didn't modify bar!). But if I observe bar itself then it'll be fine.
The sample code:
HTMLBar:
{{test-cpnt foo=foo bar=bar}}
<input type="button" {{action 'tap'}} value="tap"/>
Controller:
foo: 1,
bar: 100,
actions: {
tap: function(){
this.set('foo', this.get('foo')+1);
}
}
Component:
App.TestCpntComponent = Ember.Component.extend({
barObv1: Ember.observer('bar', function(){
console.log('bar observer is fired!');
}),
barObv2: Ember.observer('attrs.bar', function(){
console.log('attrs.bar observer is fired!');
}),
});
By tapping the button to change foo's value, we will trigger barObv2 as well. I've created a jsbin for demo: https://jsbin.com/qiwivu/2/edit?js,console,output
Does anyone know why the observer got triggered?