startWatching static method
void
startWatching({})
Watches for new builds: once at startup, every interval, and whenever the tab is brought
back to the foreground. Safe to call before runApp. End it with stopWatching.
The startup check is silentOnStart because nothing is in flight yet, so reloading costs the
user nothing and needs no navigator. Later checks use silent, which defaults to asking
first — a reload in the middle of a half-filled form would throw that input away.
Implementation
static void startWatching({
Duration interval = const Duration(minutes: 15),
bool silent = false,
bool checkNow = true,
bool silentOnStart = true,
bool onVisible = true,
bool bustUrl = false,
}) {
if (!UApp.isWeb) return;
stopWatching();
_timer = Timer.periodic(interval, (_) => unawaited(checkAndRefresh(silent: silent, bustUrl: bustUrl)));
if (onVisible) _visibilityDisposer = UWebBridge.listenVisible(() => unawaited(checkAndRefresh(silent: silent, bustUrl: bustUrl)));
if (checkNow) unawaited(checkAndRefresh(silent: silentOnStart, bustUrl: bustUrl));
}