Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

debounce typescript

// Not the best, but doesn't have <any> types, 
// the `let timer` has, but the eslint won't complicate
export default function (fn: () => void, delay = 300) {
  let timer
  return (() => {
    clearTimeout(timer)
    timer = setTimeout(() => fn(), delay)
  })()
}
 
PREVIOUS NEXT
Tagged: #debounce #typescript
ADD COMMENT
Topic
Name
7+4 =