[hammerspoon] add a debounce function
change wzkossxkrxrysnumvmlvoslpznypxutv
commit dc12bfc64f250a8484ba913887cd3290261b7ac2
author Alpha Chen <alpha@kejadlen.dev>
date
parent mowrsztl
diff --git a/.hammerspoon/utils.fnl b/.hammerspoon/utils.fnl
index bb93fc2b..3666065d 100644
--- a/.hammerspoon/utils.fnl
+++ b/.hammerspoon/utils.fnl
@@ -41,4 +41,11 @@
     (cb)
     (set ax-app.AXEnhancedUserInterface prev-val)))
 
-{: chomp : paste : replace-selection : run : with-ax-hotfix}
+(fn debounce [delay f]
+  (var timer nil)
+  (fn []
+    (when timer
+      (timer:stop))
+    (set timer (hs.timer.doAfter delay f))))
+
+{: chomp : debounce : paste : replace-selection : run : with-ax-hotfix}