The nested method calls when constructing TDirectoryWatcherBuilder is a nice idea.
However I think the user should have an option to use a more traditional way of setting properties.
For example there should be:
property Recursive: Boolean read FRecursively write FRecursively;
property OnDirectoryChanged: TDirectoryEvent read FCallBack write FCallBack;
Note the naming convention for the event property, they typically start with On...
The event type itself could be TDirectoryChangedEvent, and the event variable could be FOnDirectoryChanged instead of FCallBack.
The event handler in the example is poorly named. It should be DirectoryChanged or maybe FileChanged instead of OnFileEvent.
Is there a need to separate events for directories and files?
@hnb, you are an FPC developer, or at least a semi-developer due to your generics collection work.
Can you influence this DirectoryWatcher going into FPC libs?
We can also ask about it in fpc-dev list.