UNPKG

fe-core-cli

Version:

All-in-one scaffolding, cli integrated with Vue3 ecological chain, cli of H5 page, mock template cli of Node

21 lines (19 loc) 472 B
import { ref, unref } from 'vue' // eslint-disable-next-line no-unused-vars export function useLockFn<P extends any[] = any[], V = any>(fn: (...args: P) => Promise<V>) { const lockRef = ref(false) return async function (...args: P) { if (unref(lockRef)) { return } lockRef.value = true try { const ret = await fn(...args) lockRef.value = false return ret } catch (e) { lockRef.value = false throw e } } }