MCPcopy
hub / github.com/duke-git/lancet / Delay

Function Delay

function/function.go:79–85  ·  view source on GitHub ↗

Delay make the function execution after delayed time. Play: https://go.dev/play/p/Ivtc2ZE-Tye

(delay time.Duration, fn any, args ...any)

Source from the content-addressed store, hash-verified

77// Delay make the function execution after delayed time.
78// Play: https://go.dev/play/p/Ivtc2ZE-Tye
79func Delay(delay time.Duration, fn any, args ...any) {
80 // Catch programming error while constructing the closure
81 mustBeFunction(fn)
82
83 time.Sleep(delay)
84 unsafeInvokeFunc(fn, args...)
85}
86
87// Debounced creates a debounced function that delays invoking fn until after wait duration have elapsed since the last time the debounced function was invoked.
88// Deprecated: Use Debounce function instead.

Callers 2

ExampleDelayFunction · 0.85
TestDelayFunction · 0.85

Calls 2

mustBeFunctionFunction · 0.85
unsafeInvokeFuncFunction · 0.85

Tested by 2

ExampleDelayFunction · 0.68
TestDelayFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…