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

Callback logic #48

Open
jssuttles opened this issue Jan 18, 2024 · 1 comment
Open

Callback logic #48

jssuttles opened this issue Jan 18, 2024 · 1 comment

Comments

@jssuttles
Copy link

jssuttles commented Jan 18, 2024

https://github.com/scottcorgan/tiny-emitter/blob/4e6b2eb5869fb4ba862accaef7d16a7051349f4f/index.js#L58C6-L58C16

Doesn't this ternary statement mean that if the callback isn't found in the list of associated callbacks, then it'll remove all associated callbacks?

@scottcorgan
Copy link
Owner

What I remember this being for is to delete only the referenced callback, and reassign the remaining event callbacks to the current event listening object.

It's a bunch of awkward code to avoid memory leaks and unnecessary allocations.

This was a long time ago, so apologies if I'm not remembering correctly.

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

No branches or pull requests

2 participants