Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch and unwatch from inside event handler #17

Open
Alphapage opened this issue Aug 5, 2023 · 0 comments
Open

Watch and unwatch from inside event handler #17

Alphapage opened this issue Aug 5, 2023 · 0 comments

Comments

@Alphapage
Copy link

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant