grafana/public/app/features/explore/utils/debounce.ts
2018-09-24 12:16:06 +02:00

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);
};
}