Skip to content

Commit

Permalink
listen to ydoc destroy event
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed Dec 6, 2020
1 parent d9f2b28 commit 253c554
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"yjs": "^13.2.0"
},
"peerDependenies": {
"yjs": "^13.0.0"
"yjs": "^13.4.6"
},
"optionalDependencies": {
"ws": "^7.2.0"
Expand Down
3 changes: 3 additions & 0 deletions src/y-webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,8 @@ export class WebrtcProvider extends Observable {
}
})
this.connect()
this.destroy = this.destroy.bind(this)
doc.on('destroy', this.destroy)
}

/**
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 253c554

Please sign in to comment.