startWatching static method

void startWatching({
  1. Duration interval = const Duration(minutes: 15),
  2. bool silent = false,
  3. bool checkNow = true,
  4. bool silentOnStart = true,
  5. bool onVisible = true,
  6. bool bustUrl = false,
})

Checks at startup, every interval and when the tab comes back (initU() calls it silently).

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));
}