Skip to content
A debouncer written in Go.
Go
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Add a parallel test May 10, 2016
.travis.yml Update Travis config Feb 2, 2019
LICENSE Initial commit Apr 23, 2016
README.md Simplify implementation using time.AfterFunc Feb 2, 2019
debounce.go Make the add method thread safe Feb 2, 2019
debounce_test.go Make the add method thread safe Feb 2, 2019
go.mod Add go.mod Feb 1, 2019
go.sum Simplify implementation using time.AfterFunc Feb 2, 2019

README.md

Go Debounce

Build Status GoDoc Go Report Card codecov Release

Example

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
}
You can’t perform that action at this time.