From 716c49a270e4be5e5276192092c292f72ffcfa19 Mon Sep 17 00:00:00 2001 From: David Luecke Date: Tue, 12 Jul 2022 17:21:22 -0700 Subject: [PATCH] fix(socketio-client): Make Socket.io client event target compatible (#2686) --- packages/socketio-client/test/index.test.ts | 4 ++++ packages/transport-commons/src/client.ts | 2 ++ 2 files changed, 6 insertions(+) diff --git a/packages/socketio-client/test/index.test.ts b/packages/socketio-client/test/index.test.ts index e7d45fbfa4..a39f8f84e6 100644 --- a/packages/socketio-client/test/index.test.ts +++ b/packages/socketio-client/test/index.test.ts @@ -88,6 +88,10 @@ describe('@feathersjs/socketio-client', () => { } }) + it('is event target compatible', async () => { + app.service('todo').addEventListener('created', (data: any) => assert.ok(data)) + }) + it('calls .customMethod', async () => { const service = app.service('todos') const result = await service.customMethod({ message: 'hi' }) diff --git a/packages/transport-commons/src/client.ts b/packages/transport-commons/src/client.ts index 33ff5a2d2b..2cf8b0a1ec 100644 --- a/packages/transport-commons/src/client.ts +++ b/packages/transport-commons/src/client.ts @@ -7,6 +7,7 @@ const debug = createDebug('@feathersjs/transport-commons/client') const namespacedEmitterMethods = [ 'addListener', + 'addEventListener', 'emit', 'listenerCount', 'listeners', @@ -15,6 +16,7 @@ const namespacedEmitterMethods = [ 'prependListener', 'prependOnceListener', 'removeAllListeners', + 'removeEventListener', 'removeListener' ] const otherEmitterMethods = ['eventNames', 'getMaxListeners', 'setMaxListeners']