debounce = (fn, delay) => {
    debounceInterval && clearTimeout(debounceInterval);
    debounceInterval = setTimeout(() => {
      debounceInterval = null;
      fn();
    }, delay);
  }
Delays function execution by given threshold.
@param fn {Function}
@param delay {Integer}