https://github.com/bep/debounce
A debouncer written in Go.
https://github.com/bep/debounce
Last synced: 12 months ago
JSON representation
A debouncer written in Go.
- Host: GitHub
- URL: https://github.com/bep/debounce
- Owner: bep
- License: mit
- Created: 2016-04-23T13:33:19.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-11-27T12:47:58.000Z (over 1 year ago)
- Last Synced: 2025-04-13T22:39:20.396Z (about 1 year ago)
- Language: Go
- Size: 17.6 KB
- Stars: 128
- Watchers: 3
- Forks: 16
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Go Debounce
[](https://github.com/bep/debounce/actions?query=workflow:Test)
[](https://godoc.org/github.com/bep/debounce)
[](https://goreportcard.com/report/github.com/bep/debounce)
[](https://codecov.io/gh/bep/debounce)
[](https://github.com/bep/debounce/releases/latest)
## Example
```go
func ExampleNew() {
var counter uint64
f := func() {
atomic.AddUint64(&counter, 1)
}
debounced := debounce.New(100 * time.Millisecond)
for i := 0; i < 3; i++ {
for j := 0; j < 10; j++ {
debounced(f)
}
time.Sleep(200 * time.Millisecond)
}
c := int(atomic.LoadUint64(&counter))
fmt.Println("Counter is", c)
// Output: Counter is 3
}
```