Add early callback #13
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Builds on top of the previous PR. Early callbacks will be run before the stores and indexes are added and deleted, allowing for such early callbacks to run idb-schema methods like
addStore. This is needed by theidb-importproject I am working on now, to allow specification of imports by JSON (without my needing to reinvent the wheel with your methods).It is also needed because the other PR allows normal callbacks to execute, as before, after the other methods, but in a way which supports promises--by having them run during the
successevent instead of duringupgradeneededwhenschema.openorschema.upgradeare used (it wouldn't make sense to use them inschema.callbacksince that is automatically going to be withinupgradeneeded); there should therefore also be a way to run a callback within theupgradeneededtransaction, e.g., to check the current object stores and conditionally add one if not present.