Skip to content

Instantly share code, notes, and snippets.

@itzaks
Created December 11, 2014 13:14
Show Gist options
  • Select an option

  • Save itzaks/b0da3858bccbf07157d2 to your computer and use it in GitHub Desktop.

Select an option

Save itzaks/b0da3858bccbf07157d2 to your computer and use it in GitHub Desktop.
tiny coffeescript debounce function
debounce = (timeout, fn, timer = null) -> ->
clearTimeout timer
timer = setTimeout fn, timeout
@itzaks
Copy link
Author

itzaks commented Dec 11, 2014

Example:

$(window).on 'resize', debounce 50, ->
  console.log 'resized'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment