• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.gitignoreH A D02-Feb-2019287

.travis.ymlH A D02-Feb-2019280

LICENSEH A D02-Feb-20191.1 KiB

README.mdH A D02-Feb-2019982

debounce.goH A D02-Feb-20191 KiB

debounce_test.goH A D02-Feb-20192.3 KiB

go.modH A D02-Feb-201931

go.sumH A D02-Feb-20190

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