From b0075ac82e3f76d5833501f482af4d068111ccee Mon Sep 17 00:00:00 2001 From: Kristine Harutyunyan Date: Tue, 18 Jun 2024 16:53:22 +0400 Subject: [PATCH] fix(Messaging): Fix memory leak on unsubscribe --- README.md | 2 +- src/modules/messaging.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 68daa81..be9f85c 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ client.messaging.subscribe('topic', (data) => { ``` #### Unsubscribe from the topic - + To unsubscribe from the topic: ```ts client.messaging.unsubscribe('topic'); diff --git a/src/modules/messaging.ts b/src/modules/messaging.ts index 180ed87..dbe9e6a 100644 --- a/src/modules/messaging.ts +++ b/src/modules/messaging.ts @@ -40,6 +40,8 @@ export class Messaging implements IMessaging { const queryId = this.genId(); this.socket.write(unsubscribe(queryId, topic)); + + this.listeners.delete(topic); } trigger(message: MessagingEvent) {