debounce

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Copyright 2021 k0s authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package debounce provides functionality to "debounce" multiple events in given interval and handle all at once For debounce pattern, see https://drailing.net/2018/01/debounce-function-for-golang/ As you can see, we draw some inspiration from that example. :) Currently this is tied to fsnotify.Event as the event type since Go prohibits us to use fully generic chan interface{} type Or rather, we cannot assign chan fsnotify.Event channel type to chan interface{} If this pattern becomes common we'll need to look at something like https://github.com/eapache/channels/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func(arg fsnotify.Event)

Callback defines the callback function when we trigger the debounce action

type Debouncer

type Debouncer interface {
	Stop()
	Start()
}

Debouncer defines the debouncer interface

func New

func New(interval time.Duration, input chan fsnotify.Event, callback Callback) Debouncer

New creates new Debouncer with given args

Jump to

Keyboard shortcuts

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