indexeddb-promises
indexeddb-promises copied to clipboard
"waiting" as state or orthogonal concept?
As hinted at in #9 the state transitions are complicated. If all waiting promises resolve while performing event firing (which will dispatch to a target, execute microtasks, dispatch to the next target, execute more microtasks, etc) the state should flip to "active" not "inactive". There are a few ways to do this:
- Track an additional "is dispatching" flag
- Add "waiting-active" and "waiting-inactive"
- Drop "waiting" entirely as a state, and use "has unresolved waiting promises" as the thing which holds the tx open
- Don't exit "waiting" until a subsequent turn of the event loop so that all target dispatches/microtasks will see it as "waiting".
I have this prototyped with the first (an "is dispatching" flag) but it feels wrong. I'm thinking about dropping "waiting" as an actual state. And if that's the case should we eliminate the .state
property?