Updates ✨
feat: add keyed debounce (#20) by @rexfordessilfie
Perform debouncing by key based on a dynamic keyFn()
function which receives the function arguments. Only function calls that return the same value from the keyFn()
debounce each other!
Example
- Synchronizing form updates across input fields with a server in real-time
import { debounce } from 'ts-wrappers'
const onChangeForm = debounce(600, {
keyFn: (event) => event.target.name, // debounce calls by the form field name
})((event) => {
const data = { [event.target.name]: event.target.value };
fetch("/api/todolist", {
method: "POST",
body: JSON.stringify(data),
}).catch(e => console.log(e))
});
Other Changes
- docs: add docs benchmark script by @rexfordessilfie in #18
- docs: remove tables from performance section by @rexfordessilfie in #19
Full Changelog: v0.0.1...v0.0.2