Documentation
¶
Index ¶
- func GetFileName(path string) (string, error)
- type DevWatch
- func (h *DevWatch) AddDirectoryToWatcher(path string) error
- func (h *DevWatch) AddFilesEventHandlers(handlers ...FilesEventHandlers)
- func (h *DevWatch) Contain(path string) bool
- func (h *DevWatch) FileWatcherStart(wg *sync.WaitGroup)
- func (h *DevWatch) InitialRegistration()
- func (dw *DevWatch) Logger(messages ...any)
- func (dw *DevWatch) Name() string
- func (h *DevWatch) RemoveDirectoryFromWatcher(path string) error
- func (dw *DevWatch) SetLog(f func(message ...any))
- func (dw *DevWatch) SetShouldWatch(f func() bool)
- func (dw *DevWatch) SetWatcher(w *fsnotify.Watcher)
- func (dw *DevWatch) Watcher() *fsnotify.Watcher
- type FilesEventHandlers
- type FolderEvent
- type WatchConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFileName ¶
GetFileName returns the filename from a path Example: "theme/index.html" -> "index.html"
Types ¶
type DevWatch ¶
type DevWatch struct {
*WatchConfig
// contains filtered or unexported fields
}
func New ¶
func New(c *WatchConfig) *DevWatch
func (*DevWatch) AddDirectoryToWatcher ¶ added in v0.0.51
AddDirectoryToWatcher adds a directory and its subdirectories to the watcher.
func (*DevWatch) AddFilesEventHandlers ¶
func (h *DevWatch) AddFilesEventHandlers(handlers ...FilesEventHandlers)
AddHandlers allows adding handlers dynamically after DevWatch initialization. This is useful when handlers are created after the watcher starts (e.g., deploy handlers). The method extracts UnobservedFiles from each handler and adds them to the no_add_to_watch map.
func (*DevWatch) FileWatcherStart ¶
func (*DevWatch) InitialRegistration ¶
func (h *DevWatch) InitialRegistration()
func (*DevWatch) RemoveDirectoryFromWatcher ¶ added in v0.0.51
RemoveDirectoryFromWatcher removes a directory and its subdirectories from the watcher.
func (*DevWatch) SetShouldWatch ¶ added in v0.0.49
SetShouldWatch sets a function that determines if the file watcher should start.
func (*DevWatch) SetWatcher ¶ added in v0.0.49
SetWatcher sets the fsnotify.Watcher in a thread-safe way.
type FilesEventHandlers ¶
type FilesEventHandlers interface {
MainInputFileRelativePath() string // eg: go => "app/server/main.go" | js =>"app/pwa/public/main.js"
// NewFileEvent handles file events (create, remove, write, rename).
NewFileEvent(fileName, extension, filePath, event string) error
SupportedExtensions() []string // eg: [".go"], [".js",".css"], etc.
UnobservedFiles() []string // eg: main.exe, main.js
}
FilesEventHandlers unifies asset and Go file event handling. It allows handlers to specify which file extensions they support and how to process them.
type FolderEvent ¶
event: create, remove, write, rename
type WatchConfig ¶
type WatchConfig struct {
AppRootDir string // eg: "home/user/myNewApp"
FilesEventHandlers []FilesEventHandlers // All file event handlers are managed here
FolderEvents FolderEvent // when directories are created/removed for architecture detection
BrowserReload func() error // when change frontend files reload browser
ExitChan chan bool // global channel to signal the exit
UnobservedFiles func() []string // files that are not observed by the watcher eg: ".git", ".gitignore", ".vscode", "examples",
}