Skip to content

Commit

Permalink
Run db operations in goroutines
Browse files Browse the repository at this point in the history
  • Loading branch information
pouya-eghbali committed Mar 24, 2024
1 parent 2b6449a commit 0e5ef1f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/utils/debounce.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ func Debounce[KeyType comparable, ArgType any](

debounce.timers[key] = time.AfterFunc(wait, func() {
debounce.Lock()
defer debounce.Unlock()

delete(debounce.timers, key)
function(arg)
go func() {
delete(debounce.timers, key)
function(arg)
debounce.Unlock()
}()
})
}
}

0 comments on commit 0e5ef1f

Please sign in to comment.