microbounce ![stability](https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square)
![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)
Smol debounce package.
Usage
var Microbounce = reuqire('microbounce')
var html = require('bel')
var microbounce = Microbounce()
html`
<input onkeydown=${onkeydown}>click me</button>
`
function onkeydown (e) {
var value = e.target.value
microbounce(function () {
console.log('called at the start of a new frame', value)
})
}
Why?
Because most debounce functions don't work well when doing DOM diffing. This
package is specifically made to work well with DOM diffing.
API
microbounce = Microbounce([timeout])
Create a new instance. Timeout defaults to 256ms
.
microbounce(callback)
Debounce a callback for the duration of the timeout. The last callback wins if
called multiple times in a row.
License
MIT