mirror of
https://github.com/samber/lo.git
synced 2026-04-22 15:37:14 +08:00
fa095e4b4f
* fix(doc): fix go playground demo URL * fix(doc): add more go playground demo URL
955 B
955 B
name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
| name | slug | sourceRef | category | subCategory | playUrl | variantHelpers | similarHelpers | position | signatures | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| NewDebounceBy | newdebounceby | retry.go#L137 | core | concurrency | https://go.dev/play/p/Izk7GEzZm2Q |
|
|
10 |
|
Creates a debounced function per key that delays invoking callbacks until after the wait duration has elapsed for that key. Returns a per-key debounced function and a per-key cancel function.
debounce, cancel := lo.NewDebounceBy[string](
100*time.Millisecond,
func(key string, count int) {
println(key, count)
},
)
for i := 0; i < 10; i++ {
debounce("first")
}
time.Sleep(200 * time.Millisecond)
cancel("first")