aoe2companion icon indicating copy to clipboard operation
aoe2companion copied to clipboard

Suggestion: Debounce search

Open ryanjohndias opened this issue 4 years ago • 0 comments

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);
}

ryanjohndias avatar Oct 29 '20 12:10 ryanjohndias