So I'm trying to mimic how components do one way bindings. How would you do something like:
Parent = Ember.Object.extend({
color: 'red',
init: function() {
this.set('child', Child.create({ parent: this, colorBinding: 'parent.color' }));
}
});
Child = Ember.Object.extend({
color: undefined,
colorObserver: Ember.Observer('color', function() {
console.log('colorObserver');
}),
colorProperty: Ember.computed('color', function() {
return this.get('color');
});
});
parent = Parent.create();
So I know bindings are depreciated, but I can't find another way for Ember 1.10.1. Also, there are bugs:
colorObserver
is not called immediately whenparent.set('color')
is called (like how observers usually work).Child.create({ parent: this, colorBinding: 'parent.color' })
works, but:
_
var child = Child.create({ colorBinding: 'parent.color' });
child.set('parent', this); // does not recompute `child.get('color')` to trigger observers
Anyone have ideas?
Aucun commentaire:
Enregistrer un commentaire