Closed raineorshine closed 1 year ago
I have commented out the onblocked
handlers and added a basic test.
Emitting the blocked
event is another question. The request object is wrapped in a promise, so there is no way to bubble up the event with the existing API. The ideas I have so far are:
indexeddb
module from promise-based to event-based, returning an emitter that emits success
, error
, and blocked
events. Major change to the API..on('blocked
, ...)`. Non-breaking, but unconventional.const e = new CustomEvent('lib0.indexeddb.blocked', { detail: { request } })
dispatchEvent(e)
blocked
at all. In most cases, just waiting allows the request to complete. In hypothetical cases where it's permanently blocked, the app probably needs a timeout mechanism, which doesn't rely on the blocked
event anyway. There may be a case in the future where blocked
really does need to be detected, but it can be dealt with then.Open to your thoughts.
@dmonad
The blocked
event is, as the spec describes it, a "progress report". So there can potentially be multiple blocked
events. Hence I wouldn't go with 1-3.
I agree with 4. If the database can't be opened, we could reject the promise with a custom error. This is only necessary when opening the database - other requests can't be blocked (if I understand the spec correctly).
If you want to add a PR for this: I suggest making the timeout configurable but with a sensible default (e.g. 15s).
Thanks for the PR!
I will release it in a bit ;)
55