Skip to content

Watch and unwatch from inside event handler #17

@Alphapage

Description

@Alphapage

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions