pub fn spawn_watcher<F>(cfg: WatchConfig, on_event: F) -> Result<WatcherHandle>Expand description
Start a debounced recursive watcher.
The closure on_event is invoked once per debounce window with the
owned, deduplicated list of paths that changed outside any
cfg.ignore root. If every event in a window targets an ignored
subtree, the callback is not invoked.
Paths whose file content is byte-identical to the previous event are dropped
in the clean state, so a no-op save (e.g. repeated Ctrl+S that rewrites the
same bytes) triggers no rebuild. If retry_unchanged_when returns true,
unchanged events are forwarded so callers can retry an active error.
Deletions and files larger than an internal cap always count as changed.
Non-existent paths in cfg.paths are silently skipped; this matches
the dev-server use case where some watched directories (e.g. an
optional public/) may not exist yet.
ยงErrors
Returns an error if the watcher cannot be created or if a path that exists cannot be watched (typically a permissions issue).