Skip to content

Latest commit

 

History

History
37 lines (31 loc) · 738 Bytes

timeoutFun.md

File metadata and controls

37 lines (31 loc) · 738 Bytes

timeoutFun

为【函数】添加延迟执行的装饰器函数

Type

function useTimeoutFun<T extends Function>(fun:T, timeOut:number):{
    finished: Ref<boolean>
    fun: T
}

Params

  • fun — 需要被装饰的函数,可以为任何函数
  • timeOut — 延迟执行时间

Return

  • finished — 被等待函数的finished状态
  • fun — 装饰后的函数

Example

import { useTimeoutFun } from 'chooks'
export default {
    setup(){
        let delayFun = function () {
            // console.log("complete")
        }

        const { finished, fun } = useTimeoutFun(delayFun, 1000)

        return { 
            delayFun: fun,
            finished
        }
    }
}