To use the debounce function from the underscore library in TypeScript, you can follow these steps:
index.ts53 chars3 lines
index.ts39 chars2 lines
index.ts80 chars4 lines
index.ts53 chars2 lines
The debouncedFunction
variable will now hold a new function that will execute myFunction
only after a 500 millisecond delay between calls. You can call this new function just like the original function:
index.ts33 chars2 lines
Note that the debounce
function can also be imported from the lodash
library and has a slightly different syntax.
gistlibby LogSnag