debounce

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limiter

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

func New

func New(after time.Duration) *Limiter

New creates a debounced function that takes another functions as its argument.

func (*Limiter) Call

func (d *Limiter) Call(f func())

Call schedules the given function to be called after duration. If Call is called again before the duration expires, it will be a No-Op.

func (*Limiter) Fn

func (d *Limiter) Fn(f func())

Fn calls the given function if the debounced function is not called for the given duration. If the debounced function is called before the duration expires, the given function will not be called and the timer will be reset. This function will be called when the debounced function stops being called for the given duration. The debounced function can be invoked with different functions, if needed, the last one will win.

Jump to

Keyboard shortcuts

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