add ydoc.isDestroyed property

This commit is contained in:
Kevin Jahns 2024-09-10 15:35:46 +02:00
parent 7422b18e87
commit f604250fc3

View File

@ -104,6 +104,7 @@ export class Doc extends ObservableV2 {
* lost (with false as a parameter). * lost (with false as a parameter).
*/ */
this.isSynced = false this.isSynced = false
this.isDestroyed = false
/** /**
* Promise that resolves once the document has been loaded from a presistence provider. * Promise that resolves once the document has been loaded from a presistence provider.
*/ */
@ -322,6 +323,7 @@ export class Doc extends ObservableV2 {
* Emit `destroy` event and unregister all event handlers. * Emit `destroy` event and unregister all event handlers.
*/ */
destroy () { destroy () {
this.isDestroyed = true
array.from(this.subdocs).forEach(subdoc => subdoc.destroy()) array.from(this.subdocs).forEach(subdoc => subdoc.destroy())
const item = this._item const item = this._item
if (item !== null) { if (item !== null) {