Debouncing watcher tasks with Gulp 4
Created by: ide
With Chokidar there's no debounce option from what I've seen and instead it's up to the user of Chokidar to pass in a debounced function. So currently I do this:
gulp.watch('**/*', _.debounce(compile, 200));
Because lodash doesn't copy the provided function's name, my Gulp log says, "[03:06:06] Starting 'debounced'..." instead of "compile". The more serious issue is that the logs never say "Finished 'debounced'..." because the done
callback that gulp.watch
passed to the first invocation of the debounced function is ignored.
So what I'm looking for is an easy and reliable way to debounce gulp.watch
callbacks, possibly by adding debounce support to gulp.watch
itself via the options arg.