Skip to content

SliceMeNice-ES6/event-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

event-utils

ECMAScript 6 Event Utilities


  • debounce() returns a function, that, as long as it continues to be invoked, will not call the provided function.

debounce

Returns a function, that, as long as it continues to be invoked, will not call the provided function. The given function will be called after the debounce function has stopped being called for N milliseconds. If immediate is passed, trigger the function on the leading edge, instead of the trailing.

Example
import { debounce } from 'event-utils';

window.addEventListener( 'resize', debounce( onResize, 250, false ) );
Parameters
  • func
    the function to be invoked, when the debounce function has stopped being called for N milliseconds.

  • wait is the time to wait before calling the provided function, after the debounce function has stopped being called. If immediate is passed, this defines the time between two calls to the given function.

  • immediate (optional) defines whether to trigger the function on the leading edge, instead of the trailing.

Returns
  • A function, that, as long as it continues to be invoked, will not call the provided function.