From 89a19dec5b97047bd1e4b907179d524cdd76c107 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 14 Nov 2022 10:24:31 +0100 Subject: [PATCH] :tada: Add cljs optimized get-prop helper macro --- common/src/app/common/data.cljc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/src/app/common/data.cljc b/common/src/app/common/data.cljc index 9fa9df4f5d..ff7d98f281 100644 --- a/common/src/app/common/data.cljc +++ b/common/src/app/common/data.cljc @@ -461,6 +461,15 @@ (->> (apply c/iteration args) (concat-all))) +(defmacro get-prop + "A macro based, optimized variant of `get` that access the property + directly on CLJS, on CLJ works as get." + [obj prop] + (if (:ns &env) + (list (symbol ".") (with-meta obj {:tag 'js}) (symbol (str "-" (c/name prop)))) + `(c/get ~obj ~prop))) + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Data Parsing / Conversion ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;