Skip to content

Instantly share code, notes, and snippets.

@amir20
Created May 31, 2020 22:31
Show Gist options
  • Save amir20/bc156ead594d4199db90a3f3cf7c08c0 to your computer and use it in GitHub Desktop.
Save amir20/bc156ead594d4199db90a3f3cf7c08c0 to your computer and use it in GitHub Desktop.
import 'dart:html';
import 'dart:async';
Completer _completer = new Completer();
void main() {
MutationObserver observer = new MutationObserver(onMutation);
observer.observe(document.body, childList: true, subtree: true);
querySelector('#button').addEventListener('click', (e){
var e = new DivElement();
e.text = "Some element";
document.body.append(e);
});
_completer.future.timeout(const Duration(seconds: 5), onTimeout: () => false).then((value) {
print("value is ${value}");
});
}
void onMutation(List mutations, MutationObserver observer) {
for(var mutation in mutations){
print(mutation.addedNodes[0]);
}
_completer.complete(true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment