Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches

◆ watch()

WatchHandle Flint::AssetManager::watch ( const std::string & path,
ReloadCallback callback )
nodiscard

Register a callback to be invoked whenever path is reloaded.

The callback fires during update() after the hot-reload interval elapses and the loader reports a new revision for path. The watch is automatically cancelled when the returned WatchHandle is destroyed.

A change is delivered at most once per HOT_RELOAD_INTERVAL and only after the revision has been stable for PENDING_RELOAD_INTERVAL, so a callback can lag the file write by roughly 400 ms.

Exceptions thrown from the callback are caught and logged; the change is treated as delivered and will not be retried until the asset changes again. Callbacks run after the watch map has been scanned, so calling watch() or destroying a WatchHandle from inside one is safe.

Parameters
pathAsset path to monitor.
callbackFunction called with path when the asset changes.
Returns
A move-only handle whose lifetime controls the watch registration.