Help us shape the future of Go! Take the 2026 Go Developer Survey

cable

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: MIT Imports: 2 Imported by: 0

README

build Software License Go Report Card Docs

Cable

A utility belt package that provides functions that can throttle, debounce and schedule function calls

Install

go get github.com/jahnestacado/cable

API

Check GoDocs

License

Copyright (c) 2020 Ioannis Tzanellis
Released under the MIT license

Documentation

Overview

Package cable implements utility functions for scheduling/limiting function calls

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debounce

func Debounce(fn func(), interval time.Duration) (debouncedFunc func())

Debounce returns a function that no matter how many times it is invoked, it will only execute after the specified interval has passed from its last invocation

func DebounceImmediate

func DebounceImmediate(fn func(), interval time.Duration) (debouncedFunc func())

DebounceImmediate behaves as the Debounce function but it will also invoke the fn function immediately

func ExecuteEvery

func ExecuteEvery(interval time.Duration, fn func() bool) (cancel func())

ExecuteEvery executes function fn repeatedly with a fixed time delay(interval) between each call until function fn returns false. It returns a cancel function which can be used to cancel as well the execution of function

func ExecuteEveryImmediate

func ExecuteEveryImmediate(interval time.Duration, fn func() bool) (cancel func())

ExecuteEveryImmediate behaves as the ExecuteEvery function but it will also invoke the fn function immediately

func Throttle

func Throttle(fn func(), interval time.Duration) (throttledFunc func())

Throttle returns a function that no matter how many times it is invoked, it will only execute once within the specified interval

func ThrottleImmediate

func ThrottleImmediate(fn func(), interval time.Duration) (throttledFunc func())

ThrottleImmediate behaves as the Throttle function but it will also invoke the fn function immediately

Types

This section is empty.

Jump to

Keyboard shortcuts

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