first commit
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
||||
//#region ../../packages/hooks/use-timeout/index.d.ts
|
||||
declare function useTimeout(): {
|
||||
registerTimeout: (fn: (...args: any[]) => any, delay: number) => void;
|
||||
cancelTimeout: () => void;
|
||||
};
|
||||
//#endregion
|
||||
export { useTimeout };
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
|
||||
let _vueuse_core = require("@vueuse/core");
|
||||
|
||||
//#region ../../packages/hooks/use-timeout/index.ts
|
||||
function useTimeout() {
|
||||
let timeoutHandle;
|
||||
const registerTimeout = (fn, delay) => {
|
||||
cancelTimeout();
|
||||
timeoutHandle = window.setTimeout(fn, delay);
|
||||
};
|
||||
const cancelTimeout = () => window.clearTimeout(timeoutHandle);
|
||||
(0, _vueuse_core.tryOnScopeDispose)(() => cancelTimeout());
|
||||
return {
|
||||
registerTimeout,
|
||||
cancelTimeout
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
exports.useTimeout = useTimeout;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","names":[],"sources":["../../../../../packages/hooks/use-timeout/index.ts"],"sourcesContent":["import { tryOnScopeDispose } from '@vueuse/core'\n\nexport function useTimeout() {\n let timeoutHandle: number\n\n const registerTimeout = (fn: (...args: any[]) => any, delay: number) => {\n cancelTimeout()\n timeoutHandle = window.setTimeout(fn, delay)\n }\n const cancelTimeout = () => window.clearTimeout(timeoutHandle)\n\n tryOnScopeDispose(() => cancelTimeout())\n\n return {\n registerTimeout,\n cancelTimeout,\n }\n}\n"],"mappings":";;;;;AAEA,SAAgB,aAAa;CAC3B,IAAI;CAEJ,MAAM,mBAAmB,IAA6B,UAAkB;AACtE,iBAAe;AACf,kBAAgB,OAAO,WAAW,IAAI,MAAM;;CAE9C,MAAM,sBAAsB,OAAO,aAAa,cAAc;AAE9D,2CAAwB,eAAe,CAAC;AAExC,QAAO;EACL;EACA;EACD"}
|
||||
Reference in New Issue
Block a user