Skip to content

Change Command to not inherit from EventEmitter? #1105

@shadowspawn

Description

@shadowspawn

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    semver: majorReleasing requires a major version bump, not backwards compatible

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions