It's tempting for users to use `async` or `timeout` to try to wait for DOM updates after modifying some data. As we know, it's easy to get into a race-condition this way, and so it's an anti-pattern.
Going through our examples, I found some usage like this and wanted to replace it with a mutation observer. In all those use cases, these were one-off situations. I change this, then when the DOM updates, change that. For this reason, I coded `onMutation` as a one-time use API.
There are clearly use-cases that want continuous monitoring. It's possible to do this using onMutation, but it's not ideal (see example). We are working on a modification to make this easier, or to allow declarative monitoring of shadow-roots, light-dom, or possibly individual nodes.
Example of using onMutation for monitoring:
watchMutation: function() {
var change = function() {
this.presentationChanged();
this.onMutation(this, change);
}.bind(this);
this.onMutation(this, change);
}
Scott