Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
'use client';
import { useRef, useCallback, useEffect } from 'react';
function useTimeout(callback, delay, options = { autoInvoke: false }) {
const timeoutRef = useRef(null);
const start = useCallback(
(...args) => {
if (!timeoutRef.current) {
timeoutRef.current = window.setTimeout(() => {
callback(args);
timeoutRef.current = null;
}, delay);
}
},
[delay]
);
const clear = useCallback(() => {
if (timeoutRef.current) {
window.clearTimeout(timeoutRef.current);
timeoutRef.current = null;
}
}, []);
useEffect(() => {
if (options.autoInvoke) {
start();
}
return clear;
}, [clear, start]);
return { start, clear };
}
export { useTimeout };
//# sourceMappingURL=use-timeout.mjs.map