From 0c18c92521de8b8685882b88ad8efa74a76617c6 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 22 Jul 2023 06:03:44 -0400 Subject: [PATCH] fix: change on to always return an instance of emittery unsubscribe function --- src/index.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 8ad8f5c..06c79ec 100644 --- a/src/index.ts +++ b/src/index.ts @@ -188,10 +188,10 @@ export class Socket extends Client { await this.swarm.emit("setup", this); } - // @ts-ignore - on(event: any, listener: any): this { + on(event: any, listener: any) { + const parentOn = super.on(event, listener); if (this.eventUpdates[event]?.has(listener)) { - return this; + return parentOn; } const [update, promise] = this.connectModule( @@ -207,8 +207,7 @@ export class Socket extends Client { this.off(event as string, listener); }); - super.on(event, listener); - return this; + return parentOn; } off(event: any, listener: any): this {