diff options
| author | RanXom <saiyedshizain@gmail.com> | 2026-07-17 00:36:31 +0530 |
|---|---|---|
| committer | RanXom <saiyedshizain@gmail.com> | 2026-07-17 00:36:31 +0530 |
| commit | 9eb299c3ac08e2bea4dfe9e3355178566bcf0501 (patch) | |
| tree | eaf1922cf46b4ca9e22a45de2f07e59ea47f5ee1 /internal/watcher/watcher.go | |
| parent | d2c0c970f690d52ee3675f377a5eebc22f84afab (diff) | |
| download | galleryd-9eb299c3ac08e2bea4dfe9e3355178566bcf0501.tar.xz galleryd-9eb299c3ac08e2bea4dfe9e3355178566bcf0501.zip | |
refactor(watcher): isolate debounce loop
Diffstat (limited to 'internal/watcher/watcher.go')
| -rw-r--r-- | internal/watcher/watcher.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/internal/watcher/watcher.go b/internal/watcher/watcher.go index 1ca8e37..ee16b7b 100644 --- a/internal/watcher/watcher.go +++ b/internal/watcher/watcher.go @@ -1,11 +1,20 @@ package watcher +import "time" + type Watcher struct { config Config + + debounce chan struct{} } func New(config Config) *Watcher { + if config.Debounce <= 0 { + config.Debounce = 500 * time.Millisecond + } + return &Watcher{ - config: config, + config: config, + debounce: make(chan struct{}), } } |