staugaard / ember-resource

This project has moved. The canonical repository is now located at: https://github.com/zendesk/ember-resource
https://github.com/zendesk/ember-resource
Apache License 2.0
122 stars 27 forks source link

When changing data, notify properties will change #50

Closed dadah89 closed 11 years ago

dadah89 commented 11 years ago

Problem: data is a hash, and Ember doesn't notify when nested properties of a hash change. That means for example, if a resource has one embedded association, and after a fetch some property of this association changes, the cacheable property (association name) won't be notified and will still return an old value. i.e.:

var obj = Em.Object.create({ 
  data: { association: { name: 'foo' } }, 
  observesHash: function() { console.log('changed!'); }.observes('data')
});
obj.setPath('data.association.name', 'bar');
// => Class {__ember1352744516303_meta: Object}
obj.setPath('data', {});
// => changed! 
// => Class {__ember1352744516303_meta: Object}

/cc @shajith

shajith commented 11 years ago

I like this. Will see if I can run this by @staugaard.

staugaard commented 11 years ago

Looks good