Luxar Viewer API Documentation - v2026.10.19
    Preparing search index...

    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.
    interface UnloadHandlerPorts {
        events: EventGroup;
        dispose: () => void;
        flushPersistence?: () => void;
    }
    Index
    events: EventGroup
    dispose: () => void
    flushPersistence?: () => void

    Best-effort, synchronous-to-start persistence flush. Defaults to the OPFS index flush.