refactor: use utils.debounce

fixes socket message spam in chat resize
This commit is contained in:
Barış Soner Uşaklı
2021-10-04 10:58:32 -04:00
parent 840b49b9b2
commit a7668a7fb1
9 changed files with 68 additions and 119 deletions

View File

@@ -771,6 +771,26 @@
}
};
},
throttle: function (func, wait, immediate) {
var timeout;
return function () {
var context = this;
var args = arguments;
var later = function () {
timeout = null;
if (!immediate) {
func.apply(context, args);
}
};
var callNow = immediate && !timeout;
if (!timeout) {
timeout = setTimeout(later, wait);
}
if (callNow) {
func.apply(context, args);
}
};
},
};
return utils;