romdo/go-debounce

View on GitHub
timer.go

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
package debounce

import (
    "time"
)

const longDelay = 24 * time.Hour

// stoppedTimer returns a stopped *time.Timer created with time.AfterFunc. The
// given function is not called until the timer is restarted with Reset.
func stoppedTimer(f func()) *time.Timer {
    t := time.AfterFunc(longDelay, f)
    t.Stop()

    return t
}