import raf from '../_util/raf';
/**
 * Callback will only execute last one for each raf
 */
export default function useRafDebounce(callback) {
  let executeRef = false;
  return () => {
    if (executeRef) {
      return;
    }
    executeRef = true;
    callback();
    raf(() => {
      executeRef = false;
    });
  };
}