itinance / itinance/react-native-fs
Monitoring File Changes similar to fs.watch from node.js
- Dominant language
- C++
- Stars
- 5k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I need to watch file changes in my project. This may be a little bit advanced functionality for this repository. However, I wonder what you think about it. If you find it improper for this repository, I may open a new repo(react-native-file-observer). I am looking forward to hear your comments...
> IMPORTANT: I am not sure if Apple has any special policy about this kind of functionality in iOS apps. I didn't read any negative comment while I was searching about it. Please tell me, if you know...
Here is the API I planned to implement:
`enum ChangeEvent{`
` "ATTRIB", // Change in metadata of the file being watched`
` "MODIFY", // Change in the file being watched `
` "DELETE", // Delete the file being watched`
` "CREATE_IN_DIR", // A new file is created in the directory being watched (maybe)`
`}`
`watch(filepath: string, options: {recursive: boolean, background: boolean}, listener: function)`
Starts watching the file at given `filepath` and calls `listener` function with `(eventType, filepath)` parameters when ChangeEvent happens. `recursive` parameter indicates whether all subdirectories should be watched or not. `background` parameter indicates if watching should continue while app is background or not.
`unwatch(filepath: string, recursive: boolean, listener: function)`
If `listener` function is specified, stops calling `listener` when ChangeEvent happens in the file at given `filepath`. Otherwise, stops watching the file at given `filepath` completely, which means all of the `listener` functions for the file won't be called anymore. `recursive` parameter indicates whether all subdirectories should be unwatched or not.
I planned to base
iOS implementation on [iMonitorMyFiles](https://github.com/tblank555/iMonitorMyFiles) or I may use similar ideas explained in that repo. Thanks to @tblank555
and
Android implementation on [FileObserver Class](https://developer.android.com/reference/android/os/FileObserver.html) which looks enough for this purpose.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.