I am trying to upgrade my project to Ember 1.13 and I am a bit confused about the behavior of the new component attrs especially when I need to watch them.
For example, my test component observes bar , which is a parameter passed from the outside. I know that in Ember new Glimmer the engine when a component modifies any of its attributes. I cannot understand that the observer will also be launched at this time if I see attrs.bar (I did not change the bar !). But if I observe bar , then everything will be fine.
Code example:
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 clicking the button to change the value of foo , we will run barObv2 . I created jsbin to demonstrate: https://jsbin.com/qiwivu/2/edit?js,console,output
Does anyone know why an observer was called?
source share