Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reload delay debounce #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

romanzy313
Copy link

Added a simple de-bounce with a default delay of 200ms. On my system every file save fires the event twice, and this fixes the issue

@romanzy313
Copy link
Author

Also added a simple clearConsole option to make it easier to see reload changes

@ajinasokan
Copy link
Owner

Could you tell me your system specs? OS/arch/version? May be there is something we can do in the watcher itself.

Clear console is a nice feature 👍🏽

@romanzy313
Copy link
Author

I am running Debian 10.13 on amd64. Maybe it is an issue with my systems.

But I think it is still an important feature to include. If lets say you delete a folder with files, every file delete will trigger a reload. With delay, reload will be only triggered once as intended.

@@ -11,12 +12,15 @@ import 'package:watcher/watcher.dart';
class Recharge {
final String path;
final void Function()? onReload;
int delay;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make this Duration?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is up to you. I think keeping it the way it is now is okay too. Because delays are generally in millisecond range (500ms-20ms). 200ms seems like a good default value in my opinion

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not talking about the number. I meant to make the datatype Duration(milliseconds: 200) instead of int. It is better to use the built in datatype that is meant for this purpose.

Comment on lines +47 to +49

// print("application reloaded")

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this

@ajinasokan
Copy link
Owner

@romanzy313 Sorry got a bit busy. I will merge after these minor changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants