listen to ydoc destroy event

This commit is contained in:
Kevin Jahns 2020-12-06 15:48:07 +01:00
parent d9f2b28b2a
commit 253c554cf7
2 changed files with 4 additions and 1 deletions

View file

@ -68,7 +68,7 @@
"yjs": "^13.2.0"
},
"peerDependenies": {
"yjs": "^13.0.0"
"yjs": "^13.4.6"
},
"optionalDependencies": {
"ws": "^7.2.0"

View file

@ -582,6 +582,8 @@ export class WebrtcProvider extends Observable {
}
})
this.connect()
this.destroy = this.destroy.bind(this)
doc.on('destroy', this.destroy)
}
/**
@ -618,6 +620,7 @@ export class WebrtcProvider extends Observable {
}
destroy () {
this.doc.off('destroy', this.destroy)
// need to wait for key before deleting room
this.key.then(() => {
/** @type {Room} */ (this.room).destroy()