index.mjs 441 B

123456789101112131415161718
  1. import { tryOnScopeDispose } from '@vueuse/core';
  2. function useTimeout() {
  3. let timeoutHandle;
  4. const registerTimeout = (fn, delay) => {
  5. cancelTimeout();
  6. timeoutHandle = window.setTimeout(fn, delay);
  7. };
  8. const cancelTimeout = () => window.clearTimeout(timeoutHandle);
  9. tryOnScopeDispose(() => cancelTimeout());
  10. return {
  11. registerTimeout,
  12. cancelTimeout
  13. };
  14. }
  15. export { useTimeout };
  16. //# sourceMappingURL=index.mjs.map