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: overwrite EventBus.off method to clear once events #13736

Merged
merged 2 commits into from
Nov 14, 2024

Conversation

Antreesy
Copy link
Contributor

@Antreesy Antreesy commented Nov 8, 2024

☑️ Resolves

  • Fix stray once event listeners, if they were never called

🖌️ UI Checklist

  • test with joining call:
Before After
image image

🏁 Checklist

  • 🌏 Tested with different browsers / clients:
    • Chromium (Chrome / Edge / Opera / Brave)
    • Firefox
    • Safari
    • Talk Desktop
    • Not risky to browser differences / client
  • ⛑️ Tests are included or not possible

Copy link
Contributor

@ShGKme ShGKme left a comment

Choose a reason for hiding this comment

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

I'm not a fun of adding a new function to unsubscribe from a listener. Unlisten shouldn't be different between on and once. It has the same semantics and job. Same for other Event Emitters, including native removeEventListener.

Also, identifying a function by name is not reliable. It can be empty, it can be not unique.

Instead, let's store once handlers in a Map<type, Map<originalHandler, onceHandlers>> and override off method to support new feature.

@Antreesy Antreesy force-pushed the fix/noid/event-bus-once-garbage branch from a13e2ca to 1ca78af Compare November 8, 2024 18:38
@Antreesy Antreesy changed the title feat: introduce EventBus.cancelOnce to clear once events fix: overwrite EventBus.off method to clear once events Nov 8, 2024
@Antreesy Antreesy requested a review from ShGKme November 8, 2024 18:38
src/services/EventBus.ts Outdated Show resolved Hide resolved
src/services/EventBus.ts Outdated Show resolved Hide resolved
src/services/EventBus.ts Outdated Show resolved Hide resolved
src/services/EventBus.ts Outdated Show resolved Hide resolved
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
@Antreesy Antreesy force-pushed the fix/noid/event-bus-once-garbage branch from e5ee369 to a61b1cb Compare November 14, 2024 13:03
@Antreesy Antreesy requested a review from ShGKme November 14, 2024 13:09
@Antreesy Antreesy merged commit 437943a into main Nov 14, 2024
46 checks passed
@Antreesy Antreesy deleted the fix/noid/event-bus-once-garbage branch November 14, 2024 13:40
@Antreesy
Copy link
Contributor Author

/backport to stable30

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

Successfully merging this pull request may close these issues.

2 participants