ember.js: `notifyPropertyChange` does not propagate from controller to component
Demo: http://emberjs.jsbin.com/xufitu/3/edit?html,js,console,output
{{foo-bar myProperty=myProperty}}
<button {{action "trigger"}}>Trigger</button>
App = Ember.Application.create();
App.IndexController = Ember.Controller.extend({
myProperty: { zomg: 'lol' },
report: function() {
Em.debug('ConTROLLer: property did change!');
}.observes('myProperty'),
actions: {
trigger: function() {
this.notifyPropertyChange('myProperty');
}
}
});
App.FooBarComponent = Ember.Component.extend({
myProperty: null,
report: function() {
Em.debug('ComPONent: property did change!');
}.observes('myProperty')
});
When i trigger the controller action, i expect both observers to fire.
In reality, only the controller’s observer fires and the component’s does not.

About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 25 (19 by maintainers)
This is exactly the same “issue” as #10405. The scare quotes are because it is a misuse of the object system. And this should be resolved with the new “data down” model.
TL;DR: If you call
seton a property AND it is an object AND it is===to the existing value then observers will not be fired. Here’s the code. There are also other similar ways observers skip being fired involving chain nodes, etc.Here is the sequence of events. I hope this helps you debug in the future.
{{foo-bar myProperty=myProperty}}executes.myProperty.set(component, "myProperty", get(controller, "myProperty)). Note that this doesn’t trigger observers because objects never fire observers during the init phase.gets the value from the context (controller) andsetcontroller.notifyPropertyChange("myProperty")is called.myPropertyon the controller fire.reportobserver on the controller fires.myPropertystream binding observer fires.syncqueue, but I will omit the details of this since it’s not relevant.set(component, "myProperty", get(controller, "myProperty)). But the value hasn’t changed! So the observers formyPropertyon the component are not notified as per the TL;DR above.