Register the page-lifecycle handlers, routed through the supplied
EventGroup so every listener is removed when the parent disposes:
beforeunload tears the app down (dispose).
pagehide and visibilitychange → hidden flush persistent caches
(flushPersistence, default: every live OPFS store's pending index save).
beforeunload does not fire on mobile tab switches, bfcache navigations
or discarded tabs, so without this the L2 index written on a debounce was
routinely lost with the page, leaving thousands of unindexed chunk files
the next session could not use. The flush is best-effort and does not
dispose anything: a hidden page may well come back.
Register the page-lifecycle handlers, routed through the supplied EventGroup so every listener is removed when the parent disposes:
beforeunloadtears the app down (dispose).pagehideandvisibilitychange → hiddenflush persistent caches (flushPersistence, default: every live OPFS store's pending index save).beforeunloaddoes not fire on mobile tab switches, bfcache navigations or discarded tabs, so without this the L2 index written on a debounce was routinely lost with the page, leaving thousands of unindexed chunk files the next session could not use. The flush is best-effort and does not dispose anything: a hidden page may well come back.