mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 23:55:47 -06:00
15 lines
345 B
TypeScript
15 lines
345 B
TypeScript
// Based on underscore.js debounce()
|
|
export default function debounce(func, wait) {
|
|
let timeout;
|
|
return function(this: any) {
|
|
const context = this;
|
|
const args = arguments;
|
|
const later = () => {
|
|
timeout = null;
|
|
func.apply(context, args);
|
|
};
|
|
clearTimeout(timeout);
|
|
timeout = setTimeout(later, wait);
|
|
};
|
|
}
|