hotwatch
hotwatch copied to clipboard
Watch and unwatch from inside event handler
It doesn't seem possible to watch or unwatch files from inside the event handler. Something like this:
use hotwatch::{Hotwatch, Event, EventKind};
let mut hotwatch = Hotwatch::new().expect("hotwatch failed to initialize!");
hotwatch.watch("war.png", |event: Event| {
if let EventKind::Modify(_) = event.kind {
println!("War has changed.");
// parse file to get a list of new files to watch
event.unwatch_all();
for filepath in files {
event.watch(filepath,|event: Event| {});
}
}
}).expect("failed to watch file!");
Do you plan to implement such a feature soon ?