Skip to content

Conversation

webkonstantin
Copy link

  • update throttle and debounce description based on lodash docs
  • add additional options for throttle and debounce provided by lodash (leading, trailing and maxWait)
  • update README
  • clean PR

Allows specifying behaviour described in this issue #25 using --debounce-leading option

…ditional options for throttle and debounce provided by lodash

var debounceOpts = createDebounceOpts(opts);
var debouncedRun = _.debounce(throttledRun, opts.debounce, debounceOpts);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens here when you pass the throttled function to debounce?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing throttled function to debounce was not introduced by me in this PR, but in this commit by ElliotChong and merged before
kimmobrunfeldt/chokidar-cli@609228b#diff-168726dbe96b3ce427e7fedce31bb0bcR142

I believe it combines debounce (execute after specified ms have elapsed since the last time the debounced function was called) and throttle (do not execute more than once in specified timeframe) behaviour as you would expect without any negative side-effects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants