gulp-livereload
gulp-livereload copied to clipboard
Race condition
Hi, and thanks for this great piece of code!
Our task needs to clean the files before building new ones. Here’s a summary of our output.
[19:45:52] Starting 'demo:clean'...
[19:45:52] Finished 'demo:clean' after 172 ms
...
[19:45:53] Starting 'demo'...
[19:45:53] .../demo/dashboard.html reloaded.
[19:45:53] Finished 'demo' after 5.54 ms
The problem is that when Chrome reloads the window, it doesn’t manage to find the files. Perhaps the filesystem IO takes too long? BTW, my task looks like this:
gulp.src(settings.source)
// do stuff
.pipe(gulp.dest(settings.targetPath))
.pipe(livereload())
.once("end", function () {done();})
;
How about an option debounce? It would also prevent triggering 10 reloads one after another when 10 files are changed one after another. So this:
livereload.listen(
{ debounce: 200
});
would trigger a reload 200 ms after the last change in a series of file changes.
Here’s a nice interactive explanation of debouncing: http://reactivex.io/documentation/operators/debounce.html
+1 on this!
Hey, @tomekwi! Just wanted to let you know that I've created a standalone fork of this repo, since it doesn't seem to be maintained anymore. You can find it here.
So I might be a good idea to re-open this issue there.
Hi @leo, thanks for tackling this! I don’t really use gulp anymore – I’m doing my best to keep my builds so simple that an npm script does the job. But thumbs up and the best of luck to you!
@tomekwi Ahh, alright! :blush: