Last active
August 29, 2015 14:20
-
-
Save grav/5d36a83c6c32c05ed1d1 to your computer and use it in GitHub Desktop.
promises and clojurescript
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
(defn setup-midi! | |
[] | |
(.then (.requestMIDIAccess js/navigator) | |
(fn [midi-access] | |
(.forEach (.-outputs midi-access) | |
(fn [o] | |
(let [name (.-name o)] | |
(when (= "IAC" | |
(apply str (take 3 name))) | |
(.then (.open o) | |
(fn [o] | |
(println "setting output to" (.-name o)) | |
(swap! app-state | |
(fn [s] (update-in s [:output] (constantly o))))))))))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Naive refactor.