Smol debounce package.
var Nanobounce = require('nanobounce')
var html = require('bel')
var nanobounce = Nanobounce()
html`
<input onkeydown=${onkeydown}>click me</button>
`
function onkeydown (e) {
var value = e.target.value
nanobounce(function () {
console.log('called at the start of a new frame', value)
})
}
Because most debounce functions don't work well when doing DOM diffing. This package is specifically made to work well with DOM diffing.
Create a new instance. Timeout defaults to 256ms
.
Debounce a callback for the duration of the timeout. The last callback wins if called multiple times in a row.