Skip to content

app-nerds/debounce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Debounce

A function to execute another function after a specified delay. Really useful when you want to ensure a function isn't called too frequently. For example, if you want to send search criteria to a server after the user types, but don't wish to sent too many server calls, this method can be used.

Example

import debounce from "debounce.js";

function performSearch(term) {
   return debounce(executeSearch, 500);
}

Arguments

  • fn - The method to execute
  • delay - The delay in execution in milliseconds