Re: [w3c/IndexedDB] Add an Observer API (#51)

Garbee left a comment (w3c/IndexedDB#51)

One additional use-case for this kind of functionality and why it is important. It would allow for more automatic cleanup of run-away/potentially large stores. For example, a business requirement is that the number of entries kept locally is limited to 1,000 items. This way, we don't end up just storing tons of data over time by not pruning what hasn't been recently created.

Right now, the primary way to enforce this business requirement is creating a wrapper class to talk to IDB for the store. It is a good bit of code, most of which doesn't need to be written.

Observers would allow us to look at a given table's changes. When an `add` operation is done, lookup the count of items. If too large, remove the oldest chunk to stay in the limit. All without caring **where or how** an addition is made. No object to pull in and setup/share across an app. Just natural observation of the platform and reacting to executions.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/IndexedDB/issues/51#issuecomment-3117836629
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/IndexedDB/issues/51/3117836629@github.com>

Received on Friday, 25 July 2025 13:32:06 UTC