Skip to content

useDebounce 选项 leading 不能正常工作 #37

@junerver

Description

@junerver
if ((isMaxWait && calledCount != 0) || (calledCount == 0 && leading)) {
    task(guarantee = true, isDelay = false)
} else {
    if (calledCount > 0 && interval < wait) {
        clear()
        if (trailing) {
            task(guarantee = false, isDelay = true)
        }
    } else {
        task(guarantee = false, isDelay = true)
    }
}

由于通过calledCount == 0 && leading 判断执行了保障任务, leading 只在第一次防抖执行时工作,后续即使已经解除防抖,也不能正常触发 leading

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug(错误)Something isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions