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

Unify events and output single TypeScript declaration #2407

Merged
merged 10 commits into from
Dec 15, 2023

Conversation

DanielMcAssey
Copy link
Contributor

@DanielMcAssey DanielMcAssey commented Dec 6, 2023

Found a less destructive way than my previous PR #2406

Copy from that PR:

  1. Last step from generating a single declaration file was fixing the Listenable, to correctly implement and extend EventEmitter instead of instantiating it. (As recommended by NodeJS) https://nodejs.org/api/events.html#events_events
  2. Updated the gen-types command to output a single declaration file, which is now referenced in package.json

Now the main potentially breaking change is:

  1. Updated to add addCancellableEventListener to return an unsubscribe function, only one instance found where it was being used. (https://github.com/jitsi/lib-jitsi-meet/pull/2407/files#diff-a8019610bebdd2b0434ac15f4fccb628880b99f223460ed38cb42f650709cea8L54)
  2. The types/auto directory is no longer generated, we could get around this by creating a new command, but I thought it was redundant.

Benefits to this

  1. Type definitions automatically imported into IDE's
  2. Easier testing the event emitter, potentially easier to mock and spy on events

What do you think @saghul ?

@jitsi-jenkins
Copy link

Hi, thanks for your contribution!
If you haven't already done so, could you please make sure you sign our CLA (https://jitsi.org/icla for individuals and https://jitsi.org/ccla for corporations)? We would unfortunately be unable to merge your patch unless we have that piece :(.

@saghul
Copy link
Member

saghul commented Dec 6, 2023

I'd call that new EventManager EventEmitter and just alias the import. IMHO it would avoid confusion.

@DanielMcAssey
Copy link
Contributor Author

@saghul good idea! All sorted now I think.

@saghul
Copy link
Member

saghul commented Dec 6, 2023

Jenkins please test this please.

1 similar comment
@saghul
Copy link
Member

saghul commented Dec 7, 2023

Jenkins please test this please.

@saghul
Copy link
Member

saghul commented Dec 7, 2023

Generally LGTM but I'd like to hear what @jallamsetty1 and @hristoterezov think.

@DanielMcAssey
Copy link
Contributor Author

Just removed the on/off alias as it was redundant on the EventEmitter as the Node EventEmitter already does this

@saghul
Copy link
Member

saghul commented Dec 12, 2023

Ping @jallamsetty1 @hristoterezov

saghul
saghul previously approved these changes Dec 14, 2023
Copy link
Member

@saghul saghul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'd do another pass (after this PR) and completely get rid of Listenable and EventManager, they really server very little purpose now.

Copy link
Member

@hristoterezov hristoterezov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Needs rebasing tho!

@DanielMcAssey
Copy link
Contributor Author

Sorted! Just fixed the conflict

@hristoterezov hristoterezov merged commit 0e9a4e2 into jitsi:master Dec 15, 2023
1 check passed
@DanielMcAssey DanielMcAssey deleted the dev/unify-events-single-ts branch December 15, 2023 23:00
subhamcyara pushed a commit to subhamcyara/lib-jitsi-meet that referenced this pull request Jul 19, 2024
* fix(events): unify events to a single EventManager type, add support for single typescript declaration

* fix(lint): fix lint

* fix(events): fix incorrect instatiation

* fix(events): clean up redundant methods

* fix(events): keep EventEmitter name, alias NodeEventEmitter

* fix(events): fix loose reference

* fix(EventEmitter): remove on/off alias as redundant

* fix(RTCUtils): bring event handlers under class to use same event emitter

* fix(RTCUtils): fix lint
subhamcyara pushed a commit to subhamcyara/lib-jitsi-meet that referenced this pull request Jul 19, 2024
* fix(events): unify events to a single EventManager type, add support for single typescript declaration

* fix(lint): fix lint

* fix(events): fix incorrect instatiation

* fix(events): clean up redundant methods

* fix(events): keep EventEmitter name, alias NodeEventEmitter

* fix(events): fix loose reference

* fix(EventEmitter): remove on/off alias as redundant

* fix(RTCUtils): bring event handlers under class to use same event emitter

* fix(RTCUtils): fix lint
subhamcyara pushed a commit to subhamcyara/lib-jitsi-meet that referenced this pull request Jul 19, 2024
* fix(events): unify events to a single EventManager type, add support for single typescript declaration

* fix(lint): fix lint

* fix(events): fix incorrect instatiation

* fix(events): clean up redundant methods

* fix(events): keep EventEmitter name, alias NodeEventEmitter

* fix(events): fix loose reference

* fix(EventEmitter): remove on/off alias as redundant

* fix(RTCUtils): bring event handlers under class to use same event emitter

* fix(RTCUtils): fix lint
subhamcyara pushed a commit to subhamcyara/lib-jitsi-meet that referenced this pull request Jul 19, 2024
* fix(events): unify events to a single EventManager type, add support for single typescript declaration

* fix(lint): fix lint

* fix(events): fix incorrect instatiation

* fix(events): clean up redundant methods

* fix(events): keep EventEmitter name, alias NodeEventEmitter

* fix(events): fix loose reference

* fix(EventEmitter): remove on/off alias as redundant

* fix(RTCUtils): bring event handlers under class to use same event emitter

* fix(RTCUtils): fix lint
subhamcyara pushed a commit to subhamcyara/lib-jitsi-meet that referenced this pull request Jul 19, 2024
* fix(events): unify events to a single EventManager type, add support for single typescript declaration

* fix(lint): fix lint

* fix(events): fix incorrect instatiation

* fix(events): clean up redundant methods

* fix(events): keep EventEmitter name, alias NodeEventEmitter

* fix(events): fix loose reference

* fix(EventEmitter): remove on/off alias as redundant

* fix(RTCUtils): bring event handlers under class to use same event emitter

* fix(RTCUtils): fix lint
subhamcyara pushed a commit to subhamcyara/lib-jitsi-meet that referenced this pull request Jul 19, 2024
* fix(events): unify events to a single EventManager type, add support for single typescript declaration

* fix(lint): fix lint

* fix(events): fix incorrect instatiation

* fix(events): clean up redundant methods

* fix(events): keep EventEmitter name, alias NodeEventEmitter

* fix(events): fix loose reference

* fix(EventEmitter): remove on/off alias as redundant

* fix(RTCUtils): bring event handlers under class to use same event emitter

* fix(RTCUtils): fix lint
subhamcyara pushed a commit to subhamcyara/lib-jitsi-meet that referenced this pull request Jul 19, 2024
* fix(events): unify events to a single EventManager type, add support for single typescript declaration

* fix(lint): fix lint

* fix(events): fix incorrect instatiation

* fix(events): clean up redundant methods

* fix(events): keep EventEmitter name, alias NodeEventEmitter

* fix(events): fix loose reference

* fix(EventEmitter): remove on/off alias as redundant

* fix(RTCUtils): bring event handlers under class to use same event emitter

* fix(RTCUtils): fix lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants