Start is a runloop to watch for files changes from the file paths added from Add()
(notifier Notification)
| 39 | |
| 40 | // Start is a runloop to watch for files changes from the file paths added from Add() |
| 41 | func (f *File) Start(notifier Notification) { |
| 42 | for { |
| 43 | select { |
| 44 | case event, ok := <-f.watcher.Events: |
| 45 | if !ok { |
| 46 | return |
| 47 | } |
| 48 | if event.Op&fsnotify.Write == fsnotify.Write { |
| 49 | notifier.WatcherItemDidChange(event.Name) |
| 50 | } |
| 51 | case err, ok := <-f.watcher.Errors: |
| 52 | if !ok { |
| 53 | return |
| 54 | } |
| 55 | notifier.WatcherDidError(err) |
| 56 | |
| 57 | case <-f.shutdown: |
| 58 | f.watcher.Close() |
| 59 | return |
| 60 | } |
| 61 | } |
| 62 | } |