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

v4.0.0 #2

Merged
merged 24 commits into from
Feb 4, 2024
Merged

v4.0.0 #2

merged 24 commits into from
Feb 4, 2024

Conversation

niklasramo
Copy link
Owner

@niklasramo niklasramo commented Jan 12, 2024

UPDATES:

  • Update deps.
  • Add CI workflows for automating tests and publishing to npm.
  • Add performance benchmarks -> npm run test-perf.
  • Performance greatly improved, up to 2-3x faster than last version, depending on the benchmark.
  • Reduce size, which is now 627 B when minified and gzipped.
  • Size limit checker to make sure the lib stays below 1kB threshold (gzipped) -> npm run test-size.
  • Allow listener id to be any value except null and undefined.
  • Add new getId option to Emitter, which allows you to define the function that creates a new event listener id for the Emitter instance by default.

BREAKING CHANGES:

  • Remove the ability to always allow unbinding a listener by the listener callback. A lot of extra code was needed for this which also caused performance degradation. Performance more than doubled in many scenarios after the feature was removed and the library's total size was reduced to 627 B when minified and gzipped.
  • Remove allowDuplicateListeners option and property from Emitter.
  • Export EmitterDedupe object which you can use as an enum. And also remove exported EventListenerIdDedupeMode type as EmitterDedupe replaces it.
  • Rename "replace" dedupe mode to "add" (for clarity).
  • Rename idDedupeMode option and property to just simply dedupe as there's no listener based deduping anymore.
  • Fix .once() behaviour to be in line with other emitters. Previously we removed all the once listeners on .emit() before we started looping and calling the listeners. While this worked fine it caused the once listeners to be called in a different order than one might be accustomed to if you would add and emit once listeners within a once listener. Now the once listeners are removed right before they are called, which is more in line what one might expect.

@niklasramo niklasramo merged commit 58e6a40 into main Feb 4, 2024
1 check passed
@niklasramo niklasramo deleted the dev branch February 4, 2024 20:54
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.

1 participant