1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

F #3951: Remove debounce function (#193)

This commit is contained in:
Sergio Betanzos 2020-09-09 10:25:09 +02:00 committed by GitHub
parent 41cc656fcf
commit 69754bf382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,18 +1 @@
export const fakeDelay = ms => new Promise(resolve => setTimeout(resolve, ms));
export const debounce = (func, delay, immediate) => {
let timerId;
return (...args) => {
const boundFunc = func.bind(this, ...args);
clearTimeout(timerId);
if (immediate && !timerId) {
boundFunc();
}
const calleeFunc = immediate
? () => {
timerId = null;
}
: boundFunc;
timerId = setTimeout(calleeFunc, delay);
};
};