debounce

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package debounce provides a single-writer trailing-edge debouncer used by the watcher subsystem to coalesce bursty filesystem events into one reload trigger.

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
}

Debouncer collects calls to Trigger inside a sliding window and fires the callback exactly once with all merged reasons after the window elapses.

It is safe for concurrent Trigger calls and survives stop/restart.

func New

func New(interval time.Duration, fn func(reason string)) *Debouncer

New constructs a Debouncer. Use Stop to release resources.

func (*Debouncer) Stop

func (d *Debouncer) Stop()

Stop disarms the timer; pending callbacks are dropped.

func (*Debouncer) Trigger

func (d *Debouncer) Trigger(reason string)

Trigger records a reason and (re)arms the window.

Jump to

Keyboard shortcuts

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