Skip to content

Add support for AddEventListenerOptions deduplication - #10

Closed
fregante wants to merge 3 commits into
masterfrom
better-deduplication
Closed

fregante wants to merge 3 commits into
masterfrom
better-deduplication

Conversation

@fregante

@fregante fregante commented May 17, 2019 •

Copy link
Copy Markdown
Owner

Fixes #9

Instead of manually handling deduplication of all the calls (keeping track of baseElement, selector, callback, options), I'm using mem to wrap the user's callback so there's always 1 unfiltered listener per 1 callback+selector.

However, mem can't handle the callback+selector pair so I'm also adding many-keys-map as mem's cache handler.

Major API changes

  • Event listeners will be bound to the delegate target, not to the base element (which was weird)
  • the TypeScript type Setup is no longer exported (it was an internal one anyway)
  • delegate now returns {remove: [function]} instead of {destroy: [function]}

@fregante fregante changed the title Add support for AddEventListenerOptions deduplication Add support for AddEventListenerOptions deduplication May 17, 2019
@fregante

Copy link
Copy Markdown
Owner Author

I don't know if the simplification of the delegate-its code is worth the size and speed decrease:

  package            size     minified  gzipped
  [email protected]  4.62 KB  1.34 KB   550 B
  this PR            14.7 KB  4.77 KB   1.79 KB     (because of mem and many-keys-map)

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.

Duplicate detection is broken when using options rather than the capture boolean

1 participant