demo · v132
The replacement: polling estimate() on a schedule
Removing the EventTarget surface means no storagepressure push notification. The recommended pattern is a periodic poll of navigator.storage.estimate() — cheap because the value is cached by the browser. Tune the cadence and watch the bar fill as you write IndexedDB rows.
checking storage.estimate…
awaiting first estimate…
recommended pattern
async function watchStorage(intervalMs, warnPct) {
let last = 0;
setInterval(async () => {
const { quota, usage } = await navigator.storage.estimate();
const pct = usage / quota * 100;
if (pct > warnPct && pct > last + 1) prune();
last = pct;
}, intervalMs);
}