mklabs / tiny-lr

tiny livereload
MIT License
424 stars 90 forks source link

Delay option for server refresh #110

Open csakis opened 8 years ago

csakis commented 8 years ago

I am using a custom webserver for webpack, Whenever I modify my source files, my IDE needs 2-3 seconds to build the project and put it on the server. I would like to have an option {delay: 3000 } in tiny-lr so that my browser can refresh after a given amount of time.

mklabs commented 8 years ago

Hi @csakis

Is it something that can be done with the watcher ? I don't know if you use gulp or something else, but you might add a setTimeout(reload, 3000) or something similar ?

csakis commented 8 years ago

I use webpack and there is a plugin called webpack-livereload-plugin that uses tiny-lr. If I watch my source files being changed and initiate a browser refresh, then the browser will be refreshed too soon. It would be nice to delay the websocket message by an arbitrary number of milliseconds, so my webserver has enough time to refresh the files on the server, then the browser could refresh.

mklabs commented 8 years ago

I think this is the responsibility of webpack-livereload-plugin or more generally the build system that uses tiny-lr, what triggers the change request or event. I'm not very willing to add a option to delay message to tiny-lr itself.