ably-js icon indicating copy to clipboard operation
ably-js copied to clipboard

`EventEmitter.prototype.once(['event1', 'event2'], listener)` discards `listener`’s identity

Open lawrence-forooghian opened this issue 1 year ago • 1 comments

The case where once is passed an array of event names is implemented by wrapping the listener argument in another listener:

https://github.com/ably/ably-js/blob/76cc74fcfa66beff40f2a367c8b9b69b8aabd60e/src/common/lib/util/eventemitter.ts#L260-L273

This means that the event emitter does not hold a reference to the listener argument (other than that held indirectly through the wrapper) and so it is not possible to remove this listener using off(..., listener).

The client library specification does not specify a version of once which accepts an array of event names, and we do not advertise it as part of the public API. So, I think the simplest thing would be to remove this functionality.

┆Issue is synchronized with this Jira Bug by Unito

lawrence-forooghian avatar Sep 28 '23 18:09 lawrence-forooghian

➤ Automation for Jira commented:

The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3883

sync-by-unito[bot] avatar Sep 28 '23 18:09 sync-by-unito[bot]