initial commit

This commit is contained in:
陈文彬
2020-09-28 20:19:10 +08:00
commit 2f6253cfb6
436 changed files with 26843 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
import type { TimeoutFnResult, Fn } from './types';
import { isFunction } from '/@/utils/is';
import { watch } from 'vue';
import { useTimeoutRef } from '/@/hooks/core/useTimeoutRef';
export function useTimeout(handle: Fn<any>, wait: number): TimeoutFnResult {
if (!isFunction(handle)) {
throw new Error('handle is not Function!');
}
const [readyRef, clear, runAgain] = useTimeoutRef(wait);
watch(
readyRef,
(maturity) => {
maturity && handle();
},
{ immediate: false }
);
return [clear, runAgain, readyRef];
}