import { ref } from 'vue'

export function  useLockFn(fn: (...args: any[]) => Promise<any>) {
    const isLock = ref(false)
    const lockFn = async (...args: any[]) => {
        if (isLock.value) return
        isLock.value = true
        try {
            await fn(...args)
        } finally{
            isLock.value=false
        }
    }
    return {
        isLock,
        lockFn
    }
}
