From c82c3b71d819b4f8c4eacf1e3aa909569026ea1e Mon Sep 17 00:00:00 2001 From: Nathan Marz Date: Mon, 13 Jun 2016 15:26:08 -0400 Subject: [PATCH] add note about not being able to use collected? inline in a path when using cljs, disable that test for cljs --- src/clj/com/rpl/specter/macros.clj | 6 +++++- test/com/rpl/specter/core_test.cljx | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/clj/com/rpl/specter/macros.clj b/src/clj/com/rpl/specter/macros.clj index 65bc229..972db0f 100644 --- a/src/clj/com/rpl/specter/macros.clj +++ b/src/clj/com/rpl/specter/macros.clj @@ -624,7 +624,11 @@ "Creates a filter function navigator that takes in all the collected values as input. For arguments, can use `(collected? [a b] ...)` syntax to look at each collected value as individual arguments, or `(collected? v ...)` syntax - to capture all the collected values as a single vector." + to capture all the collected values as a single vector. + + For ClojureScript, since can't use macros inside path when that path will be + inline factored/cached, to use collected? declare the logic in a global + variable such as (def my-collected (collected? [v] (= v 1)))" [params & body] `(i/collected?* (fn [~params] ~@body)) ) diff --git a/test/com/rpl/specter/core_test.cljx b/test/com/rpl/specter/core_test.cljx index ec8c48b..81c02fd 100644 --- a/test/com/rpl/specter/core_test.cljx +++ b/test/com/rpl/specter/core_test.cljx @@ -1224,6 +1224,10 @@ m) ))) + +;; clojure only because inability to use macroexpand inside path macro in +;; clojurescript makes it impossible to use macros inside the path +#+clj (deftest collected?-test (let [data {:active-id 1 :items [{:id 1 :name "a"} {:id 2 :name "b"}]}] (is (= {:id 1 :name "a"}