"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = useRafDebounce;
var _raf = _interopRequireDefault(require("../_util/raf"));
/**
 * Callback will only execute last one for each raf
 */
function useRafDebounce(callback) {
  let executeRef = false;
  return () => {
    if (executeRef) {
      return;
    }
    executeRef = true;
    callback();
    (0, _raf.default)(() => {
      executeRef = false;
    });
  };
}