-
Notifications
You must be signed in to change notification settings - Fork 752
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Debounce/Throttle option? #134
Comments
Forgot to mention I tried both the |
…sarily. Solves BrowserSync#134 I added a `debounce` option that when used turns the change callback function into a debounced function a la Lodash that will wait `options.debounce` milliseconds since the last call to actually execute. If the `debounce` option isn't provided or is 0, then it behave as it did before this change.
In testing, #135 does solve my issue. With a debounce of 100ms, it does trigger 2 change events, but it appears to be because of 2 different steps in my build, so it's likely because there is a > 100ms gap between the two steps. But regardless, I can either increase the debounce, or live with 2 change events (which I can definitely live with). 2 is much better than a couple dozen and |
fileTimeout was removed as it was still very unreliable. When you think about it, adding a debounce/throttle is always going to be prone to errors because the actual compilation time is unknown. (although I'm still happy to have a debounce option - I just don't think it's the best solution) There's already a way to emit file change events to Browser Sync (see the last example here) & that way you can remove the file watching altogether and handle it manually. (although it's still not Ideal if you don't know the file names). Ideally going forward, I want something like this to work:
That's one of the big goals of next release. |
That's a better approach! Good call. |
^ hoping to have the improvement to gulp workflow above released tonight/tomorrow :) |
on npm at version 0.8.0 |
@shakyShane by the way, the new way of putting it at the end of the pipe works really nice. It was a good call. =) |
Yeah, I did look up the official usage, first. |
I'm working on a larger project with a lot of CoffeeScript files. When I change one of the files, it currently reprocesses all of those files, and
browser-sync
is watching the compiles JS.When I save a CoffeeScript file, I get the following output:
It seems like a throttle and/or debounce option might help here. We only need to reload the browsers one time for this batch of files. If I had a debounce of even 100ms, I don't think it'd crash like this.
The text was updated successfully, but these errors were encountered: