Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK-3883] Remove ability to pass array of event names to EventEmitter.prototype.once #1453

Conversation

lawrence-forooghian
Copy link
Collaborator

This functionality is implemented by wrapping the listener argument in another listener. 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 is to remove this functionality.

Resolves #1452.

@github-actions github-actions bot temporarily deployed to staging/pull/1453/features September 28, 2023 18:32 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1453/bundle-report September 28, 2023 18:33 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1453/typedoc September 28, 2023 18:34 Inactive
@lawrence-forooghian lawrence-forooghian changed the title Remove ability to pass array of event names to EventEmitter.prototype.once [SDK-3883] Remove ability to pass array of event names to EventEmitter.prototype.once Sep 28, 2023
@lawrence-forooghian lawrence-forooghian force-pushed the 1452-remove-EventEmitter-once-multiple-events branch from 8a2d2ab to 412534c Compare September 28, 2023 18:47
@github-actions github-actions bot temporarily deployed to staging/pull/1453/features September 28, 2023 18:48 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1453/bundle-report September 28, 2023 18:49 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/1453/typedoc September 28, 2023 18:49 Inactive
….once

This functionality is implemented by wrapping the listener argument in
another listener.  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 is to remove this
functionality.

Resolves #1452.
@owenpearson
Copy link
Member

I'm don't think outright removing this is a good idea - the method is still useful as long as you don't have a need to remove the listener? I agree the implementation is bad but this is a breaking change to something that, at least partially, works. I think the only real options pre-v2 of the library are to soft-deprecate/add a warning or to just fix it.

@lawrence-forooghian
Copy link
Collaborator Author

Thanks @owenpearson, I've created #1470 and will put it in the v2 epic.

@lawrence-forooghian
Copy link
Collaborator Author

Closing this since we decided in #1470 that we'll fix and keep.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

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