debouncer

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: Unlicense Imports: 2 Imported by: 1

README

New() creates a debouncer that runs any function it is given to in some delay.
Every time .Call() is called that countdown is reset (or started) and the function to be run is overwritten.
Calling .Flush() fires the last called function immediately.
.IsRunning() can be called to check if there is any countdown happening.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Debouncer

type Debouncer struct {
	// contains filtered or unexported fields
}

func New

func New(delay time.Duration) *Debouncer

func (*Debouncer) Call

func (d *Debouncer) Call(f func())

Call schedules a new call, overwrites the previous

func (*Debouncer) Flush

func (d *Debouncer) Flush()

Flush calls the last debounced function immediately

func (*Debouncer) IsRunning

func (d *Debouncer) IsRunning() bool

IsRunning returns true if there is a timer running already, false if not

func (*Debouncer) Stop added in v0.3.1

func (d *Debouncer) Stop()

Stop cancels everything that might be running

Jump to

Keyboard shortcuts

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