From b6924411f983b4d071ee9ee757e807668c0eb8bc Mon Sep 17 00:00:00 2001 From: Paik Date: Wed, 21 Aug 2024 18:04:33 +0900 Subject: [PATCH] Fix bug in subscribeBroadcastEvent method --- packages/sdk/src/document/document.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/sdk/src/document/document.ts b/packages/sdk/src/document/document.ts index 4583db233..b78fa3eb2 100644 --- a/packages/sdk/src/document/document.ts +++ b/packages/sdk/src/document/document.ts @@ -1061,7 +1061,7 @@ export class Document { ): Unsubscribe { this.broadcastEventHandlers.set(topic, handler); - this.eventStream.subscribe((event) => { + const unsubscribe = this.eventStream.subscribe((event) => { for (const docEvent of event) { if (docEvent.type !== DocEventType.Broadcast) { continue; @@ -1074,6 +1074,7 @@ export class Document { }, error); return () => { + unsubscribe(); this.broadcastEventHandlers.delete(topic); }; }