use notify::{Config, RecommendedWatcher, Watcher};
use std::sync::mpsc::channel;
use std::time::Duration;
use crate::services::git_watcher::{GitWatchConfig, GitWatcher};
impl GitWatcher {
pub fn with_config(config: GitWatchConfig) -> Result<Self, notify::Error> {
let (tx, rx) = channel();
let watcher = RecommendedWatcher::new(
move |res| {
let _ = tx.send(res);
},
Config::default().with_poll_interval(Duration::from_millis(config.debounce_ms)),
)?;
Ok(Self {
watcher,
rx,
config,
repo_path: None,
has_pending_changes: false,
})
}
}