nice-mutation-observer

1.0.1 • Public • Published

nice-mutation-observer

Mutation Observer with a nicer api

Usage

// Install on Element prototype
import 'nice-mutation-observer/install';

const el = document.getElementById('app');

const config = { attributes: true, childList: true, characterData: true }
const disconnect = el.observe('childList', config, (mutation) => {
  console.log('change!', mutation)
})

// Disconnect
disconnect();

Without global prototype

import observe from 'nice-mutation-observer';

const el = document.getElementById('app');

const config = { attributes: true, childList: true, characterData: true }
const disconnect = observe(el, 'childList', config, (mutation) => {
  console.log('change!', mutation)
})

// Disconnect
disconnect();

Readme

Keywords

none

Package Sidebar

Install

npm i nice-mutation-observer

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

2.62 kB

Total Files

6

Last publish

Collaborators

  • gabemeola