Created
May 17, 2016 20:55
-
-
Save candera/329f1d4df430bbc15bff97778f950d5e to your computer and use it in GitHub Desktop.
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
(let [opacity-ch (async/chan (async/dropping-buffer 1))] | |
(async/go-loop [last-set (:opacity @app-state) | |
last-received nil] | |
(let [t (async/timeout 100) | |
[ch val] (async/alts! [t opacity-ch]) | |
[new-set new-received] (cond | |
(= ch opacity-ch) | |
[last-set val] | |
(not= last-set last-received) | |
(do | |
(swap! app-state assoc :opacity last-received) | |
[last-received last-received]) | |
:else | |
[last-set last-received])] | |
(recur new-set new-received))) | |
(defn opacity-change | |
[e] | |
(let [opacity (-> e .-target .-value (/ 100.0))] | |
(async/go (>! opacity-ch opacity))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment