Last active
October 24, 2015 00:03
-
-
Save xfsnowind/3a145751a881c179a7ce to your computer and use it in GitHub Desktop.
usage debounce-clj on blog "Debounce and Throttle in Clojure" on 2015/10/24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def sync-source (chan)) | |
(def sync-sink (debounce sync-source 10000)) | |
(defn handle-event! [event] | |
(when-let | |
[handler (case (:type event) | |
:one-event function-wanna-call | |
unknown-event)] | |
(try | |
(apply handler (:args event)) | |
(catch Exception e nil)))) | |
(go-loop [] (handle-event! (<! sync-sink))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment