UNPKG

1.13 kBTypeScriptView Raw
1import { Disposable, DisposableLike, FilesystemChangeEvent } from '../index';
2
3/** Manage a subscription to filesystem events that occur beneath a root directory. */
4export interface PathWatcher extends DisposableLike {
5 /**
6 * Return a Promise that will resolve when the underlying native watcher is
7 * ready to begin sending events.
8 */
9 getStartPromise(): Promise<void>;
10
11 /** Invokes a function when any errors related to this watcher are reported. */
12 onDidError(callback: (error: Error) => void): Disposable;
13
14 /**
15 * Unsubscribe all subscribers from filesystem events. Native resources will be
16 * released asynchronously, but this watcher will stop broadcasting events
17 * immediately.
18 */
19 dispose(): void;
20}
21
22/**
23 * Invoke a callback with each filesystem event that occurs beneath a specified path.
24 * If you only need to watch events within the project's root paths, use
25 * Project::onDidChangeFiles instead.
26 */
27export function watchPath(
28 rootPath: string,
29 options: {},
30 eventCallback: (events: FilesystemChangeEvent) => void,
31): Promise<PathWatcher>;