Files
remark42/web/app/utils/debounce.js
T
Andrei Alikov 3e72ec379a Fix block users select behavior
We need to have onBlur and onChange events listeners for the select for the "block user" as it advised by es-lint. But if we simply add onBlur event listener it will cause infinite loop of blur -> confirm pop-up -> cancel -> blur -> confirm pop-up... So we have to debounce the events to process them only one time.
2019-02-06 18:50:15 +09:00

9 lines
218 B
JavaScript

export default function debounce(func, wait) {
let timeout;
return function() {
const laterCall = () => func.apply(this, arguments);
clearTimeout(timeout);
timeout = setTimeout(laterCall, wait);
};
}