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

fix: rename event emitter class #2173

Merged
merged 3 commits into from
Oct 25, 2023
Merged

Commits on Oct 25, 2023

  1. refactor!: rename event emitter class

    We add types to a EventEmitter class which extends the plain js EventTarget.
    
    The name is chosen to give familiarity to node developers but it's
    not generally a good idea.
    
    This refactor:
    
    1. Exports a new TypedEventTarget interface which adds types to EventTarget
    2. Renames EventEmitter to TypedEventEmitter to draw a distinction between them
    
    In the future all consuming code should rely on the TypedEventTarget interface
    while implemmenting code uses TypedEventEmitter as an implementation of
    a TypedEventEmitter.
    
    By depending on the interface and not the implementation consuming code is
    isolated from problems that arise when two versions of `@libp2p/interface`
    is in the dependency tree and the event subsystems would otherwise be
    compatible due to type overlap.
    
    This maifests as an error message about incompatible implementations of
    the private `#listeners` field in EventEmitter.
    achingbrain committed Oct 25, 2023
    Configuration menu
    Copy the full SHA
    7be6dfd View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    62d515f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    57a5fa7 View commit details
    Browse the repository at this point in the history