refactor(hooks): introduce vueuse, delete duplicate hooks

This commit is contained in:
vben
2020-11-12 22:40:16 +08:00
parent ecfb702b09
commit d9b1960030
48 changed files with 135 additions and 610 deletions

View File

@@ -1,23 +0,0 @@
import { isFunction } from '/@/utils/is';
import { Ref, watch } from 'vue';
import { useTimeoutRef } from '/@/hooks/core/useTimeoutRef';
type TimeoutFnResult = [Fn<void>, Fn<void>, Ref<boolean>];
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];
}