re-frame debug sub macro
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
;; A macro that replaces reg-sub, it inserts debug print statements into reg-sub if a flag of choice is set | |
;; Developed since 0.8.0 does not work with re-frame-tracer | |
;; Use it by replacing re-frame.core/reg-sub with this macro | |
(defmacro reg-sub [label & sub] | |
(let [fun (last sub) | |
arg (get-in (vec fun) [1 1 1]) | |
[before after] (split-at 2 fun) | |
new-fun (concat before [`(js/console.log "Sub: " [~label ~arg])] after)] | |
(if (= "true" env/PRODUCTION) ;; Or whatever way you want to disable this, may also be done by replacing js/console.log above | |
`(re-frame.core/reg-sub | |
~label | |
~@sub) | |
`(re-frame.core/reg-sub | |
~label | |
~@(drop-last sub) | |
~new-fun)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment