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 };
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import { tryOnScopeDispose } from "@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);
|
||||
tryOnScopeDispose(() => cancelTimeout());
|
||||
return {
|
||||
registerTimeout,
|
||||
cancelTimeout
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { useTimeout };
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.mjs","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,yBAAwB,eAAe,CAAC;AAExC,QAAO;EACL;EACA;EACD"}
|
||||
Reference in New Issue
Block a user