debounce

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2022 License: MIT Imports: 2 Imported by: 1

README

Debounce

Function debouncer.

PkgGoDev Build Status Go Report Card Coverage Status GitHub issues Release

Installation

To install the package, run:

go get github.com/go-zoox/debounce

Getting Started

import (
  "testing"
  "github.com/go-zoox/debounce"
)

func main(t *testing.T) {
	count := 0

	fn := func() {
		count++
	}
	debouncedFn := New(fn, 10*time.Millisecond)

	for i := 0; i < 100; i++ {
		debouncedFn()
	}

	time.Sleep(20 * time.Millisecond)

	fmt.Println(count)
}

Inspired By

License

GoZoox is released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "1.0.1"

Version is the current version of the package.

Functions

func New

func New(fn func(), interval time.Duration) func() error

New returns a new debounced function which will postpone its execution

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL