loaded event when loaded from persistence adapter

This commit is contained in:
Kevin Jahns
2018-01-08 02:28:46 +01:00
parent 445dd3e0da
commit 5a68b9f4ad
5 changed files with 23 additions and 3 deletions

View File

@@ -21,9 +21,12 @@ import { addStruct as addType } from './Util/structReferences.js'
import debug from 'debug'
import Transaction from './Transaction.js'
import YIndexedDB from '../../y-indexeddb/src/y-indexeddb.js'
export default class Y extends NamedEventHandler {
constructor (opts, persistence) {
super()
this._loaded = false
this._opts = opts
this.userID = opts._userID != null ? opts._userID : generateUserID()
this.share = {}
@@ -47,6 +50,15 @@ export default class Y extends NamedEventHandler {
initConnection()
}
}
get loaded () {
return this._loaded
}
set loaded (val) {
if (this._loaded === false && val) {
this._loaded = true
this.emit('loaded')
}
}
_beforeChange () {}
transact (f, remote = false) {
let initialCall = this._transaction === null