phoenixframework / phoenix_live_reload

Provides live-reload functionality for Phoenix
MIT License
315 stars 90 forks source link

Debounce live reload events #132

Closed kuon closed 1 year ago

kuon commented 1 year ago

With inotify, when using a network mount, events are duplicated, and I get a lot of Live reload:... everytime I save.

I worked around this issue using fs_poll instead of inotify.

Now I just opened https://github.com/aj-foster/phx_copy/issues/2 which is related, and it made me realize it would be cool to also debounce events in live reload itself when using inotify.

Basically, when an event E0 for file F occurs we save the timestamp of that event as TS0, we start a 100ms timer (configurable) and every time an event arrive for F we ignore it until the end of the timer, at the end of the timer, we do the reload.

josevalim commented 1 year ago

There is already such a feature: https://github.com/phoenixframework/phoenix_live_reload/blob/6771687f4652d197f4ace1b63ba6a9560d60932b/lib/phoenix_live_reload/live_reloader.ex#L36

kuon commented 1 year ago

My bad, sorry for not finding it. Cheers.

kuon commented 1 year ago

I just realized that there is no release with that feature. Do you think you could release 1.3.4 to avoid having to use master? I see that https://github.com/phoenixframework/phoenix_live_reload/issues/130 has been opened.

josevalim commented 1 year ago

There was a release last month: https://hex.pm/packages/phoenix_live_reload

kuon commented 1 year ago

Ho yes, I didn't see a tag on the repo that's why. I should have read the last commit message.

josevalim commented 1 year ago

Tag pushed.