Skip to content
Snippets Groups Projects
Commit da7e67d9 authored by Kevin Jahns's avatar Kevin Jahns
Browse files

implemented destroy & updated disconnect

parent bd54a43a
No related branches found
No related tags found
No related merge requests found
......@@ -176,9 +176,17 @@ module.exports = function (Y /* :any */) {
this.gc2 = this.gc2.filter(filter)
delete op.gc
}
destroy () {
* destroy () {
clearInterval(this.gcInterval)
this.gcInterval = null
for(var key in this.initializedTypes) {
var type = this.initializedTypes[key]
if (type._destroy != null) {
type._destroy()
} else {
console.error('The type you included does not provide destroy functionality, it will remain in memory (updating your packages will help).')
}
}
}
setUserId (userId) {
if (!this.userIdPromise.inProgress) {
......
......@@ -46,6 +46,12 @@ module.exports = function (Y /* : any*/) {
this.onevent = onevent
this.eventListeners = []
}
destroy () {
this.waiting = null
this.awaiting = null
this.onevent = null
this.eventListeners = null
}
/*
Call this when a new operation arrives. It will be executed right away if
there are no waiting operations, that you prematurely executed
......
......@@ -108,6 +108,7 @@ class YConfig {
db: Y.AbstractDatabase;
connector: Y.AbstractConnector;
share: {[key: string]: any};
options: Object;
*/
constructor (opts, callback) {
this.options = opts
......@@ -145,10 +146,17 @@ class YConfig {
return this.connector.reconnect()
}
destroy () {
this.disconnect()
this.db.destroy()
this.connector = null
this.db = null
if (this.connector.destroy != null) {
this.connector.destroy()
} else {
this.connector.disconnect()
}
var self = this
this.db.requestTransaction(function * () {
yield* self.db.destroy()
self.connector = null
self.db = null
})
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment