You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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);
});
The text was updated successfully, but these errors were encountered:
erikzenker
changed the title
Add onEventWatchFile and onEventWatchPathRecursively to NotifierBuilder
Add onEventWatchFile or onEventWatchPathRecursively to NotifierBuilder
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)
The text was updated successfully, but these errors were encountered: