From d4fa61e4358bdc83173c346121c992836f1b7152 Mon Sep 17 00:00:00 2001 From: mo8it Date: Thu, 26 Sep 2024 12:26:24 +0200 Subject: Debounce file change events --- src/watch.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/watch.rs') diff --git a/src/watch.rs b/src/watch.rs index fd89b29..11450b4 100644 --- a/src/watch.rs +++ b/src/watch.rs @@ -69,11 +69,11 @@ fn run_watch( // Prevent dropping the guard until the end of the function. // Otherwise, the file watcher exits. let _watcher_guard = if let Some(exercise_names) = notify_exercise_names { + let notify_event_handler = + NotifyEventHandler::build(watch_event_sender.clone(), exercise_names)?; + let mut watcher = RecommendedWatcher::new( - NotifyEventHandler { - sender: watch_event_sender.clone(), - exercise_names, - }, + notify_event_handler, Config::default().with_poll_interval(Duration::from_secs(1)), ) .inspect_err(|_| eprintln!("{NOTIFY_ERR}"))?; -- cgit v1.2.3