Created
May 26, 2021 19:33
-
-
Save rishabhshuklax/cd932eb55a421e9c35f381ac4b759135 to your computer and use it in GitHub Desktop.
Notify User upon change in any property of a certain element, takes the className as an input param for attatching the observer
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 notifyMe = (className, title = 'Room status changed', body = 'Someone entered the room') => { | |
var target = $(`.${className}`); | |
const observer = new MutationObserver(function(mutations) { | |
const notification = new Notification(title, { body }); | |
}); | |
// configuration of the observer: | |
const config = { attributes: true, childList: true, characterData: true }; | |
// pass in the target node, as well as the observer options | |
observer.observe(target, config); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment