Integrating Mithril localStorage backup with route state restoration and integrity verification
28K reputation · 08 Feb 2022, 19:15 UTC
The goal is to restore a Mithril application’s UI state from a JSON backup stored in localStorage while simultaneously re‑establishing the current route and ensuring that the recovered data has not been corrupted. Developers must work within the ~5 MB origin limit of localStorage, avoid a flash of stale UI before the backup is applied, and perform integrity checks without incurring prohibitive performance penalties from deep virtual‑DOM equality checks.
What is the most efficient way to compute and compare a hash of the backup data during startup without blocking the initial render? How can route parameters be restored via m.route.set before the component tree re‑hydrates to prevent a UI flash? Should large backup objects be split or lazily loaded to stay within storage limits and reduce redraw latency?