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

Add onEventWatchFile or onEventWatchPathRecursively to NotifierBuilder #43

Open
erikzenker opened this issue Dec 11, 2018 · 0 comments
Open
Assignees
Labels
API Issues related to the inotify-cpp API enhancement

Comments

@erikzenker
Copy link
Owner

erikzenker commented Dec 11, 2018

It is a common pattern to add a watch to files or folders which were created. Currently, it is possible to watch these files by a bit complicated code shown in a test case. To simplify the code one could add the following method to the NotifierBuilder:

    auto notifier = BuildNotifier()
            .watchPathRecursively(testDirectory_)
            .onEventWatchPathRecursively(Event::create | Event::isDir);
            .onEventWatchFile(Event::create);

or maybe with predefined actions. It would keep the API more clean. But overloading the method is not good practice. So give it a new name e.g.: onEventDoPredefinedAction ? (to long IMHO)

    auto notifier = BuildNotifier()
            .watchPathRecursively(testDirectory_)
            .onEvent(Event::create, Action::watchFile);
            .onEvent(Event::create | Event::isDir, Action::watchPath); // same as watchFile but more convenient
            .onEvent(Event::create | Event::isDir, Action::watchPathRecursively);
});
@erikzenker erikzenker self-assigned this Dec 11, 2018
@erikzenker erikzenker changed the title Add onEventWatchFile and onEventWatchPathRecursively to NotifierBuilder Add onEventWatchFile or onEventWatchPathRecursively to NotifierBuilder Dec 11, 2018
@erikzenker erikzenker added the API Issues related to the inotify-cpp API label Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Issues related to the inotify-cpp API enhancement
Projects
None yet
Development

No branches or pull requests

1 participant