Vixen
02b45cc4
csharp
public sealed class HotReloadWatcher

Watches a directory of .vcss files and reloads the ones it knows.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Only stylesheets. A changed .vxml is not something a watcher can act on — the file has to become a different Build method first, and that is a compile — so the markup channel is driven by MetadataUpdate instead. Watching for a file this cannot use would put a spinner on an operation that never happens.

⚠ Editors write files more than once. Save-to-temp-then-rename, a truncate followed by a write, a tool that touches the timestamp afterwards — one save can raise three events, and reloading three times means two rebuilds nobody asked for. Changes are coalesced by path and applied on Poll, which the frame loop calls; that also puts the reload on the caller's thread, which matters because the element tree has no lock and a FileSystemWatcher callback is on a pool thread.

Events (1)

  • public Action<ReloadReport>? Reloaded

    Raised for every reload the watcher applies.

Methods (4)

  • public HotReloadWatcher(HotReloadHost host, string directory)

    Watches a directory.

  • public int Load(string path)

    Loads a stylesheet and remembers where it came from.

  • public IReadOnlyList<ReloadReport> Poll()

    Applies whatever has changed since the last call.

  • public void Dispose()

    Stops watching.