Documentation ¶
Overview ¶
Package cable implements utility functions for scheduling/limiting function calls
Index ¶
- func Debounce(f func(), interval time.Duration, options DebounceOptions) func()
- func SetInterval(f func() bool, interval time.Duration) func()
- func SetTimeout(f func(), interval time.Duration) func()
- func Throttle(f func(), interval time.Duration, options ThrottleOptions) func()
- type DebounceOptions
- type ThrottleOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debounce ¶
func Debounce(f func(), interval time.Duration, options DebounceOptions) 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 SetInterval ¶
SetInterval executes function f repeatedly with a fixed time delay(interval) between each call until function f returns false. It returns a cancel function which can be used to cancel aswell the execution of function f
func SetTimeout ¶
SetTimeout postpones the execution of function f for the specified interval. It returns a cancel function which when invoked earlier than the specified interval, it will cancel the execution of function f. Note that function f is executed in a different goroutine
func Throttle ¶
func Throttle(f func(), interval time.Duration, options ThrottleOptions) func()
Throttle returns a function that no matter how many times it is invoked, it will only execute once within the specified interval
Types ¶
type DebounceOptions ¶
type DebounceOptions struct {
Immediate bool
}
DebounceOptions is used to further configure the behavior of a debounced-function
type ThrottleOptions ¶
type ThrottleOptions struct {
Immediate bool
}
ThrottleOptions is used to further configure the behavior of a throttled-function