From 253c554cf7db28315815944b31326ca810cd5076 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sun, 6 Dec 2020 15:48:07 +0100 Subject: [PATCH] listen to ydoc destroy event --- package.json | 2 +- src/y-webrtc.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index b491802..072158b 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "yjs": "^13.2.0" }, "peerDependenies": { - "yjs": "^13.0.0" + "yjs": "^13.4.6" }, "optionalDependencies": { "ws": "^7.2.0" diff --git a/src/y-webrtc.js b/src/y-webrtc.js index 1eec6da..aafcab2 100644 --- a/src/y-webrtc.js +++ b/src/y-webrtc.js @@ -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()