clojure-toolbox.com
clojure-toolbox.com copied to clipboard
Add debounce to search
This makes the UI feel far less laggy while typing in a search query. It avoids applying redundant searches, which can easily add up to ~150ms per character on an older device or mobile phone.
This seems fine in principle. Can we use rest arguments to make the debouncer more concise?
function debounce(f, wait){
var timeout;
return function(...args) {
clearTimeout(timeout)
timeout = setTimeout(f.bind(this, ...args), wait);
}
}
Also instead of applySearch
maybe filterProjectsBySearch
?
var filterProjectsBySearch = debounce(function(query) {
...
}, 100);
I've applied the rename suggestion.
The downside to using spread is that Internet Explorer support is non-existent. Is Internet Explorer support still a goal for clojure-toolbox?
The downside to using spread is that Internet Explorer support is non-existent. Is Internet Explorer support still a goal for clojure-toolbox?
I don't believe it's ever been a goal. If someone needs IE support and raises an issue then we can revisit this, but I think it's safe to assume IE use amongst Clojure programmers is low to non-existent.
As that's the case, I've pushed a shorter implementation using ES6.