Back to Lo

Core Newthrottleby

docs/data/core-newthrottleby.md

1.53.0267 B
Original Source

Creates a throttled function per key.

go
throttle, reset := lo.NewThrottleBy[string](
    100*time.Millisecond,
    func(key string) {
        println(key)
    },
)

for i := 0; i < 10; i++ {
    throttle("foo");
    time.Sleep(30*time.Millisecond)
}

reset()