Skip to content

Instantly share code, notes, and snippets.

@andrewluetgers
Created December 14, 2017 16:39
Show Gist options
  • Save andrewluetgers/b8ac8750a08f9ff9cc28c833a13a446d to your computer and use it in GitHub Desktop.
Save andrewluetgers/b8ac8750a08f9ff9cc28c833a13a446d to your computer and use it in GitHub Desktop.
memoized debounce
// debounce function if arguments do not change
// https://github.com/lodash/lodash/issues/2403#issuecomment-290760787
function activate(func, wait=0, options={}) {
var mem = _.memoize(function() {
return _.debounce(func, wait, options)
}, options.resolver);
return function(){mem.apply(this, arguments).apply(this, arguments)}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment