aoe2companion
aoe2companion copied to clipboard
Suggestion: Debounce search
Currently, when the user types in the search field, it appears that every key press triggers an api call. Ideally, this should be debounced, to save on bandwidth usage for both the user as well as the server. It will also lead to better UX where the search results won't change so often ("flicker")
I may attempt a PR on this, but my primary experience is in native iOS, so I'm not sure I'll be able to.
For what it's worth, this is what I use in one of my small projects:
var timerId;
var debounce = function (func, delay) {
// Cancels the setTimeout method execution
clearTimeout(timerId);
// Executes the func after delay time (milliseconds)
timerId = setTimeout(func, delay);
}