Reputation: 2589
Say I have a custom element, who has a @observable Map model = toObservable({'k': 'v'});
in its dart file, and <span>{{model['k']}}</span>
in its html file, when I changed model
, how can I know, without using MutationObserver
to observe DOM, that the new value is applied to DOM?
Upvotes: 1
Views: 78
Reputation: 657058
You can listen to model.changes
but this is also what Polymer does. To execute your code after Polymer added the elements to the DOM you can delay your code like
model.changes.listen((changes) {
new Future(() => doSomethingAfterDomUpdate());
});
This way you give Polymer time to complete its updates.
Upvotes: 1
Reputation: 5662
You have to use toObservable() on your map, otherwise new values will not be inserted.
Why do you need to know when new values are updated in the DOM? If you really need it you can listen to the changes
of the ObservableMap
.
Upvotes: 1