hotwatch icon indicating copy to clipboard operation
hotwatch copied to clipboard

Watch and unwatch from inside event handler

Open Alphapage opened this issue 2 years ago • 0 comments

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 ?

Alphapage avatar Aug 05 '23 17:08 Alphapage