fix(loginUsername): add throttle for search (#39)

This commit is contained in:
BeADre 2020-10-22 17:21:23 +08:00 committed by GitHub
parent f99dbac95f
commit af30eb431d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -58,3 +58,13 @@ export function shuffleAList(list) {
});
return newSorts;
}
export function throttle(fn, time) {
let isRun = false;
return function () {
if (isRun) return;
isRun = true;
fn.apply(this, arguments);
setTimeout(() => { isRun = false }, time);
}
}