Created
July 14, 2014 21:15
-
-
Save verma/a8560f22cdae3e7709fb 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
(defmacro bind-handlers [type node cb & specs] | |
(let [attacher (if (= type :value) | |
'addValueEventListener | |
'addChildEventListener)] | |
`(cond | |
~@(for [[matchtype iface handler] specs] | |
(list | |
`(= ~type ~matchtype ) | |
`(. ~node ~attacher (reify ~iface | |
(~handler [this v] | |
(~cb (.getValue v)))))))))) | |
(bind-handlers a b c [:value com.firebase.Test onDataChange]) | |
;; What I am getting right now: | |
(clojure.core/cond ((clojure.core/= a :value) (. b addChildEventListener (clojure.core/reify com.firebase.Test (onD | |
ataChange [pani.core/this pani.core/v] (c (.getValue pani.core/v))))))) | |
;; What I want | |
(clojure.core/cond (clojure.core/= a :value) (. b addChildEventListener (clojure.core/reify com.firebase.Test (onD | |
ataChange [pani.core/this pani.core/v] (c (.getValue pani.core/v)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment