watch
Starts watching a file or directory for filesystem changes. Returns an FSWatcher handle that can be used to stop watching.
FSWatcher
The FSWatcher type has a single method:
close(): void, stops watching and releases all resources.
Signature
watch(path: string): Result<FSWatcher, FsError>FSWatcherEvent
FSWatcherEvent describes an event record with readonly kind: string and path: string fields. The current watch API returns only an FSWatcher handle and does not expose an event subscription method.
Example
tyrus
import { FsError, watch } from "tyrus:fs";
match (watch("./logs")) {
Ok(watcher) => {
print("watching logs"); // watching logs
watcher.close();
}
Err(error) => { printError(error.code); } // ERR_FS_WATCH_FAILED
}