Skip to content

v0.0.2

Latest
Compare
Choose a tag to compare
@rexfordessilfie rexfordessilfie released this 16 Sep 07:10
· 4 commits to main since this release
ca87e02

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

Full Changelog: v0.0.1...v0.0.2