Skip to content

Reload delay debounce#4

Open
romanzy313 wants to merge 2 commits intoajinasokan:masterfrom
romanzy313:master
Open

Reload delay debounce#4
romanzy313 wants to merge 2 commits intoajinasokan:masterfrom
romanzy313:master

Conversation

@romanzy313
Copy link
Copy Markdown

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
Copy Markdown
Author

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

@ajinasokan
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread lib/recharge.dart
class Recharge {
final String path;
final void Function()? onReload;
int delay;
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 thread lib/recharge.dart
Comment on lines +47 to +49

// print("application reloaded")

Copy link
Copy Markdown
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
Copy Markdown
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