0.0.9 • Published 7 years ago

cth-mutant v0.0.9

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

TODO: Rewrite/finish

This object encapsulates MutationObserver and adds a pleasant .reconnect() method. If you use MutationObservers quite often and want a simpler syntax, try this.

.disconnect() and .reconnect() are sometimes a handy pair to use when we want to listen for a change in the DOM, suspend the listening, make our changes, and resume the listening.

Usage goes something like:

API 1 - like standard, but just provide the callback as 3rd parameter.

// Duplicate the object, OLOO style
const myObserver = Object.create(Mutant)

myObserver.observe(document, {childList: true}, function(muts){
  muts.forEach(mut => {
    console.log(mut)
  })
})

API 2 - explicit

const myObserver2 = Object.create(Mutant)

myObserver2.observe({
    target: document,
    config: {childList: true},
    callback: function (muts) {
        muts.forEach(mut => {
          console.log(mut)
        })
    }
})

API 3 - chained

const myObserver3 = Object.create(Mutant)

myObserver3
.observe({
    target: document,
    config: {childList: true}
})
.tap(function(muts){
    muts.forEach(mut => {
      console.log(mut)
    })
})

(;,;)

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago