grafana/public/app/containers/Explore/utils/debounce.ts
2018-08-30 08:53:13 +02:00

15 lines
350 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 = function() {
timeout = null;
func.apply(context, args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}