Files
lo/docs/data/core-newdebounce.md
T
2025-10-06 19:59:26 +02:00

906 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
NewDebounce newdebounce retry.go#L54 core concurrency https://go.dev/play/p/mz32VMK2nqe
core#concurrency#newdebounce
core#concurrency#newdebounceby
core#concurrency#newthrottle
core#concurrency#newthrottleby
core#concurrency#newtransaction
core#concurrency#synchronize
0
func NewDebounce(duration time.Duration, f ...func()) (func(), func())

Creates a debounced function that delays invoking the callbacks until after the wait duration has elapsed since the last call. Returns the debounced function and a cancel function.

debounce, cancel := lo.NewDebounce(
    100 * time.Millisecond,
    func() {
        println("Called once after debounce!")
    },
)

for i := 0; i < 10; i++ {
    debounce()
}

time.Sleep(200 * time.Millisecond)
cancel()