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) {