Closed jlukic closed 4 years ago
Hi @jlukic, thanks for opening the issue.
I agree that global click event handler costs a bit but I'm not sure it is worth optimized. Does it cause performance issues in your app?
I'm working on a single page app with something like 50+ distinct pages. Only a few of them use the textcomplete component, however all click events on all pages fire the textcomplete document event handler.
There's no specific issue with the event handler performing poorly, however the design might cause memory issues. The event handler carries a reference to dropdownViews
which prevents it from being garbage collected by the browser.
There's currently a bubbled event being watched on
document
that appears to be bound todocument
regardless of whether atextcomplete
component is initialized.Attaching an event handler on every bubbled click event is fairly expensive. This most likely should be part of the components
initialize
anddestroy
method, so that it doesn't continue to evaluate on every click event in your site/app.To make sure its attached once across components you'll most likely need to use some novel strategy, but it could be accomplished using something like unique ids, or namespaced events.