fixed several consistency issues with y-indexeddb. Implemented support for .close() - a soft replacement for .destroy()

This commit is contained in:
Kevin Jahns
2016-10-31 01:17:24 +01:00
parent 8ab16f4ada
commit f32ff1b613
5 changed files with 40 additions and 18 deletions

View File

@@ -239,10 +239,7 @@ module.exports = function (Y /* :any */) {
this.gc2 = this.gc2.filter(filter)
delete op.gc
}
* destroy () {
clearInterval(this.gcInterval)
this.gcInterval = null
this.stopRepairCheck()
destroyTypes () {
for (var key in this.initializedTypes) {
var type = this.initializedTypes[key]
if (type._destroy != null) {
@@ -252,6 +249,11 @@ module.exports = function (Y /* :any */) {
}
}
}
* destroy () {
clearInterval(this.gcInterval)
this.gcInterval = null
this.stopRepairCheck()
}
setUserId (userId) {
if (!this.userIdPromise.inProgress) {
this.userIdPromise.inProgress = true
@@ -434,8 +436,7 @@ module.exports = function (Y /* :any */) {
*/
* operationAdded (transaction, op) {
if (op.struct === 'Delete') {
var target = yield* transaction.getInsertion(op.target)
var type = this.initializedTypes[JSON.stringify(target.parent)]
var type = this.initializedTypes[JSON.stringify(op.targetParent)]
if (type != null) {
yield* type._changed(transaction, op)
}
@@ -503,10 +504,8 @@ module.exports = function (Y /* :any */) {
resolve: resolve,
promise: promise
}
return promise
} else {
return this.transactionsFinished.promise
}
return this.transactionsFinished.promise
} else {
return Promise.resolve()
}