Preparing search index...

    Watches a file or directory for changes and emits events when modifications occur.

        // Watcher monitors a filesystem path for additions, modifications, moves,
    // and removals. Create one via the static Watcher.create(path) method,
    // connect to its signals, then call start() to begin watching.

    const { Watcher } = await import('LensStudio:FileSystem');
    const model = this.pluginSystem.findInterface(Editor.Model.IModel) as Editor.Model.IModel;
    const assetsDir = model.project.assetsDirectory;

    // Create a watcher on the project's assets directory
    const watcher = Watcher.create(assetsDir);
    console.log('Watcher created for path:', assetsDir.toString());

    // Connect to file-change signals
    this.connections.push(
    watcher.onAdded.connect((path: Editor.Path) => {
    console.log('File added:', path.toString());
    })
    );
    this.connections.push(
    watcher.onModified.connect((path: Editor.Path) => {
    console.log('File modified:', path.toString());
    })
    );
    this.connections.push(
    watcher.onRemoved.connect((path: Editor.Path) => {
    console.log('File removed:', path.toString());
    })
    );
    this.connections.push(
    watcher.onMoved.connect((oldPath: Editor.Path, newPath: Editor.Path) => {
    console.log('File moved from', oldPath.toString(), 'to', newPath.toString());
    })
    );

    // Start watching
    watcher.start();
    console.log('Watcher is active:', watcher.isWatching);
    console.log('Watcher path:', watcher.path.toString());

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    isWatching: boolean

    Indicates whether the watcher is currently active.

    onAdded: signal1<Path, void>

    Signal emitted when a file is added at the watched path.

    onModified: signal1<Path, void>

    Signal emitted when a file is modified at the watched path.

    onMoved: signal2<Path, Path, void>

    Signal emitted when a file is moved at the watched path.

    onRemoved: signal1<Path, void>

    Signal emitted when a file is removed from the watched path.

    path: Path

    The filesystem path being monitored by this watcher.

    Methods

    • Creates a new Watcher instance for the specified path.

      Parameters

      Returns Watcher

    • Returns true if the object is of the specified type.

      Parameters

      • type: string

      Returns boolean

    • Begins watching the configured path for filesystem events.

      Returns void

    • Stops watching the configured path for filesystem events.

      Returns void