1.1.1 • Published 9 years ago

@slicemenice/event-utils v1.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

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.