Skip to content

Instantly share code, notes, and snippets.

@rishabhshuklax
Created May 26, 2021 19:33
Show Gist options
  • Save rishabhshuklax/cd932eb55a421e9c35f381ac4b759135 to your computer and use it in GitHub Desktop.
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
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