I want to be notified when an update has occurred in a related object. This plunk http://plnkr.co/edit/7thr0V demonstrates my problem.
In more detail: I pass the data object via bind [data.bind] to the user element. if I now update the property in the data, I would expect that the "dataChanged" hook in the user element is being called. If I show a property from an attached data object in a custom elements template, it is updated, so the binding itself works correctly.
My second reproach uses ObserverLocator, but it also does not run nested updates.
Object in app.js:
this.data = {
nested: {
content: "Hello nested world!"
}
};
Binding to a custom ce element:
<require from="ce"></require>
<ce data.bind="data"></ce>
Part of ce.js:
@bindable data;
constructor(observerLocator) {
this.observerLocator = observerLocator;
var subscription = this.observerLocator
.getObserver(this, 'data')
//.getObserver(this, 'data["nested"]["content"]') //Doesn't work
//.getObserver(this, 'data.nested.content') //Doesn't work
.subscribe(this.onChangeData);
}
onChangeData(newData, oldData) {
console.log('data changed from ', oldData, newData);
}
dataChanged(d) {
console.log("Changed", d);
}
ce:
${data.nested.content}
app.js 2 .
"" .
.
,
, .
setInterval(() => {
this.data.nested.content += "!";
}, 1000);
setInterval(() => {
this.data = {
nested: {
content: "Hello nested world No. " + this.counter++ + "!"
}
};
}, 5000);