Move debouncer to App.

Debounce drag of splitter and window resize
This commit is contained in:
j433866 2019-06-03 14:59:41 +01:00
parent eb91dd7a7d
commit 87dc325932
3 changed files with 28 additions and 27 deletions

View file

@ -598,28 +598,6 @@ class InputWaiter {
}
/**
* Debouncer to stop functions from being executed multiple times in a
* short space of time
* https://davidwalsh.name/javascript-debounce-function
*
* @param {function} func - The function to be executed after the debounce time
* @param {number} wait - The time (ms) to wait before executing the function
* @param {array} args - Array of arguments to be passed to func
* @returns {function}
*/
debounce(func, wait, args) {
return function() {
const context = this,
later = function() {
this.inputTimeout = null;
func.apply(context, args);
};
clearTimeout(this.inputTimeout);
this.inputTimeout = setTimeout(later, wait);
}.bind(this);
}
/**
* Handler for input change events.
* Debounces the input so we don't call autobake too often.
@ -627,7 +605,7 @@ class InputWaiter {
* @param {event} e
*/
debounceInputChange(e) {
this.debounce(this.inputChange.bind(this), 50, [e])();
this.app.debounce(this.inputChange, 50, "inputChange", this, [e])();
}
/**