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

Change Command to not inherit from EventEmitter? #1105

Closed
shadowspawn opened this issue Nov 23, 2019 · 1 comment
Closed

Change Command to not inherit from EventEmitter? #1105

shadowspawn opened this issue Nov 23, 2019 · 1 comment
Labels
semver: major Releasing requires a major version bump, not backwards compatible

Comments

@shadowspawn
Copy link
Collaborator

While working on the name pollution issue, I started thinking it could be much tidier if Command "has-a" EventEmitter rather than "is-a" EventEmitter.

I expect the primary use of EventEmitter by clients is for adding .on() callbacks. This could be offered with a delegate routine for just that, and the other EventEmitter functionality done internally using a private property.

Advantages of changing the EventEmitter usage are:

  • reduce noise in code completion suggestions in editors
  • reduce name collisions when storing option values as properties on Command
  • if clients do not need access to EventEmitter, can remove implicit dependency on TypeScript definitions for node

Do any gentle readers use more than .on() from EventEmitter?

Do you rely on this being the command object in your listener?

@shadowspawn shadowspawn added the semver: major Releasing requires a major version bump, not backwards compatible label Nov 23, 2019
@shadowspawn
Copy link
Collaborator Author

Better to stay with conventional pattern without strong case for changing, or good examples of other patterns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: major Releasing requires a major version bump, not backwards compatible
Projects
None yet
Development

No branches or pull requests

1 participant