Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gabemeola/nice-mutation-observer

Mutation Observer with a nicer api
https://github.com/gabemeola/nice-mutation-observer

Last synced: about 6 hours ago
JSON representation

Mutation Observer with a nicer api

Awesome Lists containing this project

README

        

# nice-mutation-observer
Mutation Observer with a nicer api

## Usage
```js
// 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
```js
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();
```