Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
.gitignore | H A D | 02-Feb-2019 | 287 | |||
.travis.yml | H A D | 02-Feb-2019 | 280 | |||
LICENSE | H A D | 02-Feb-2019 | 1.1 KiB | |||
README.md | H A D | 02-Feb-2019 | 982 | |||
debounce.go | H A D | 02-Feb-2019 | 1 KiB | |||
debounce_test.go | H A D | 02-Feb-2019 | 2.3 KiB | |||
go.mod | H A D | 02-Feb-2019 | 31 | |||
go.sum | H A D | 02-Feb-2019 | 0 |
README.md
1# Go Debounce 2 3[![Build Status](https://travis-ci.org/bep/debounce.svg)](https://travis-ci.org/bep/debounce) 4[![GoDoc](https://godoc.org/github.com/bep/debounce?status.svg)](https://godoc.org/github.com/bep/debounce) 5[![Go Report Card](https://goreportcard.com/badge/github.com/bep/debounce)](https://goreportcard.com/report/github.com/bep/debounce) 6[![codecov](https://codecov.io/gh/bep/debounce/branch/master/graph/badge.svg)](https://codecov.io/gh/bep/debounce) 7[![Release](https://img.shields.io/github/release/bep/debounce.svg?style=flat-square)](https://github.com/bep/debounce/releases/latest) 8 9## Example 10 11```go 12func ExampleNew() { 13 var counter uint64 14 15 f := func() { 16 atomic.AddUint64(&counter, 1) 17 } 18 19 debounced := debounce.New(100 * time.Millisecond) 20 21 for i := 0; i < 3; i++ { 22 for j := 0; j < 10; j++ { 23 debounced(f) 24 } 25 26 time.Sleep(200 * time.Millisecond) 27 } 28 29 c := int(atomic.LoadUint64(&counter)) 30 31 fmt.Println("Counter is", c) 32 // Output: Counter is 3 33} 34``` 35 36