ably-js
ably-js copied to clipboard
`EventEmitter.prototype.once(['event1', 'event2'], listener)` discards `listener`’s identity
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.
➤ Automation for Jira commented:
The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3883