ElMassimo / vite-plugin-full-reload

♻️ Automatically reload the page when files are modified
MIT License
147 stars 8 forks source link

Optimize multiple changes on the same delay #17

Open jpamador opened 1 year ago

jpamador commented 1 year ago

When there are multiple changes within the delay window right now they are just queue instead of doing one per window.

ElMassimo commented 1 year ago

Hi there!

Would you describe your use case?

jpamador commented 1 year ago

Hi!

I have an application that on certain occasions does several changes in a row to the backend. We are using your plugin (thanks btw!) with a delay of 2 seconds to give time for the backend to cool down, but what I have seen is that let's say I do 3 changes to the backend on those 2 seconds, I will then see 3 reloads, this change is to "aggregate" those changes in the delay window and just do one

ElMassimo commented 1 year ago

several changes in a row to the backend

Modifying files? Can you elaborate further?

jpamador commented 1 year ago

I'm just developing an application with frontend and backend using JS, for development purposes I have a big window on the auto-refresh so that it give me time to do changes to different files in the backend before it refreshes so that its a complete change (that may involve changing 3 files). But as I mentioned before, with the current set up, when the window is up, I get 3 refreshed back to back instead of 1.

patricknelson commented 1 year ago

Essentially this is debouncing (e.g. https://browsersync.io/docs/options#option-reloadDebounce). What he’s saying (if I’m not mistaken) is that even though there’s currently a delay, even if you make several changes very quickly within that delay, they each trigger separate reloads (based on what I’m reading above, I haven’t installed this yet 😅).

bjufre commented 1 year ago

@ElMassimo @jpamador I think that this PR is something that also might help and does what we all need in a very controlled and simple way?

Or maybe I'm misunderstanding something @jpamador?