Last active
January 4, 2020 17:08
-
-
Save Ivannnnn/2a296bbaac6f37e0cb6e7a1b64ba90c3 to your computer and use it in GitHub Desktop.
Observes changes to an element until false is returned from the callback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const observe = (el, cb, options = { childList: true }) => { | |
const func = mutations => cb(mutations) === false && mo.disconnect() | |
const mo = new MutationObserver(func) | |
mo.observe(el, options) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment