diff options
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/observe-dom.ts | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/utils/observe-dom.ts b/src/utils/observe-dom.ts new file mode 100644 index 0000000..e375326 --- /dev/null +++ b/src/utils/observe-dom.ts @@ -0,0 +1,8 @@ +export default (callback: () => boolean) => { + const observer = new MutationObserver(() => { + if (callback()) { + observer.disconnect(); + } + }); + observer.observe(document, {childList: true, subtree: true}); +}; |
