Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions debouncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ func (d *Debouncer) invokeTriggeredFunc() *time.Timer {
d.signalCalledAt = time.Now()

return time.AfterFunc(d.timeDuration, func() {
d.mu.Lock()
defer d.mu.Unlock()
d.triggeredFunc()
if d.done != nil {
close(d.done)
Expand Down Expand Up @@ -170,6 +172,8 @@ func (d *Debouncer) UpdateTimeDuration(newTimeDuration time.Duration) {

// Done returns a receive-only channel to notify the caller when the triggered func has been executed.
func (d *Debouncer) Done() <-chan struct{} {
d.mu.Lock()
defer d.mu.Unlock()
if d.done == nil {
d.done = make(chan struct{})
}
Expand Down