Fork me on GitHub
#specter
<
2016-09-07
>
amacdougall01:09:09

I'm still getting up to speed on selectors. I'm creating Hiccup-formatted SVG, and in this case, I'm trying to get the attributes map of the first rect in a g (SVG's "group" tag). This works for me, but I suspect I'm missing a better way:

(sm/select-any
  [s/ALL vector? #(= :rect (first %)) s/ALL map?]
  [:g
   [:line {:x1 0 :y1 0 :x2 100 :y2 100}]
   [:rect {:x 1 :y 2 :width 100 :height 200}]])

nathanmarz01:09:47

@amacdougall if the attributes map is always the last element of the vector you can end with LAST instead of [ALL map?]

amacdougall01:09:23

Ah, good point! In this case, I think it will be, because the rects are leaf nodes in the SVG tree. For other constructs, this may not hold true, but that's another story.

nathanmarz01:09:51

you can also use keypath to navigate by index into a vector

amacdougall01:09:20

I suppose in this case, it's okay to assume a lot about the structure of the target. But one of my favorite things about Specter is that paths can be quite flexible. Just trying to develop good habits.

nathanmarz01:09:33

yea just takes practice

levitanong07:09:27

I’m getting ERROR: contains? not supported on type: clojure.lang.PersistentList when requiring specter. Am I doing anything wrong? The following is my require clause in ns: (:require [com.rpl.specter :refer [ALL FIRST]])

levitanong07:09:10

this is on specter 0.13.0. Specter 0.12.0 works just fine

nathanmarz11:09:05

@levitanong is this Clojure or ClojureScript? do you have a full stack trace?

levitanong11:09:33

clojurescript

levitanong11:09:46

hang on, will come up with the full stack trace

nathanmarz11:09:37

@levitanong what version of cljs?

nathanmarz11:09:27

I just pushed a build that renames that function, might fix it

nathanmarz11:09:31

try 0.13.1-SNAPSHOT

levitanong18:09:45

@nathanmarz Works perfectly, thanks 🙂

darwin21:09:24

just upgraded to 0.13.0, started getting TypeError: this.$late1$.$select_STAR_$ is not a function, looks like I didn’t include something?

darwin22:09:13

investigating it more, this looks like advanced-mode optimization problem

darwin22:09:28

I’m compiling my cljs code under :advanced with :pseudo-names true (running my tests against advanced mode build)

nathanmarz22:09:11

@darwin so you don't get the error under a different optimization mode?

darwin22:09:11

trying to test that, but my project is pretty complex and I bumped into another issue with :none mode

darwin22:09:17

will get back to you ASAP

nathanmarz22:09:26

also, you should try 0.13.1-SNAPSHOT

darwin22:09:41

ok, going to do that first

nathanmarz22:09:49

what version of cljs are you using?

darwin22:09:23

so 0.13.1-SNAPSHOT behaves the same way for me under :advanced, now I’m going to make that :none mode work

darwin22:09:42

just need to mess with goog/base.js require which is missing for some reason

darwin22:09:27

this is fun, I’m depending on parinfer package from cljsjs and it has missing semicolon in a wrong place, advanced mode optimizer seems to “fix” it and in :none :simple / :whitespace mode browser throws, this will be hard to fix quickly...

darwin22:09:52

maybe I will just try to isolate my specter usage into a standalone project and demonstrate the issue there (if exists)