From 158904f480e558ca00f680e7c577bb6329605eff Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 5 May 2024 18:05:30 +0200 Subject: refactor: only reload templates when such files are updated --- internal/server/dev.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'internal/server/dev.go') diff --git a/internal/server/dev.go b/internal/server/dev.go index 52ab29b..1318801 100644 --- a/internal/server/dev.go +++ b/internal/server/dev.go @@ -44,7 +44,7 @@ func (watcher FileWatcher) AddRecursive(from string) error { return errors.WithMessage(err, "error walking directory tree") } -func (watcher FileWatcher) Start(callback func()) { +func (watcher FileWatcher) Start(callback func(string)) { for { select { case event := <-watcher.Events: @@ -61,7 +61,7 @@ func (watcher FileWatcher) Start(callback func()) { } } if event.Has(fsnotify.Rename) || event.Has(fsnotify.Write) { - callback() + callback(event.Name) time.Sleep(500 * time.Millisecond) } case err := <-watcher.Errors: -- cgit 1.4.1