index.js 520 B

12345678910111213141516171819202122
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var core = require('@vueuse/core');
  4. function useTimeout() {
  5. let timeoutHandle;
  6. const registerTimeout = (fn, delay) => {
  7. cancelTimeout();
  8. timeoutHandle = window.setTimeout(fn, delay);
  9. };
  10. const cancelTimeout = () => window.clearTimeout(timeoutHandle);
  11. core.tryOnScopeDispose(() => cancelTimeout());
  12. return {
  13. registerTimeout,
  14. cancelTimeout
  15. };
  16. }
  17. exports.useTimeout = useTimeout;
  18. //# sourceMappingURL=index.js.map