Skip to content

Commit

Permalink
fix(store): add dispose method to collection (#8852)
Browse files Browse the repository at this point in the history
  • Loading branch information
EYHN authored Dec 4, 2024
1 parent c9eaf82 commit 923161f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/framework/store/src/store/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ export class DocCollection extends DocCollectionAddonType {
return this.getDoc(docId, { query }) as Doc;
}

dispose() {
this.awarenessStore.destroy();
}

/**
* Terminate the data sync process forcefully, which may cause data loss.
* It is advised to invoke `canGracefulStop` before calling this method.
Expand Down
6 changes: 2 additions & 4 deletions packages/framework/store/src/yjs/awareness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,8 @@ export class AwarenessStore<Flags extends BlockSuiteFlags = BlockSuiteFlags> {
}

destroy() {
if (this.awareness) {
this.awareness.off('change', this._onAwarenessChange);
this.slots.update.dispose();
}
this.awareness.off('change', this._onAwarenessChange);
this.slots.update.dispose();
}

getFlag<Key extends keyof Flags>(field: Key) {
Expand Down

0 comments on commit 923161f

Please sign in to comment.