This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-07
Channels
- # admin-announcements (2)
- # arachne (1)
- # bangalore-clj (2)
- # beginners (39)
- # boot (349)
- # cider (31)
- # clara (2)
- # cljs-dev (9)
- # cljsjs (67)
- # cljsrn (7)
- # clojure (300)
- # clojure-art (4)
- # clojure-greece (11)
- # clojure-hk (3)
- # clojure-israel (1)
- # clojure-italy (17)
- # clojure-japan (1)
- # clojure-russia (33)
- # clojure-sg (2)
- # clojure-spec (41)
- # clojure-uk (86)
- # clojurescript (123)
- # clojurex (3)
- # code-reviews (1)
- # component (6)
- # crypto (1)
- # cursive (36)
- # datomic (32)
- # devcards (3)
- # emacs (11)
- # events (3)
- # funcool (4)
- # luminus (10)
- # om (28)
- # onyx (88)
- # pedestal (2)
- # re-frame (84)
- # reagent (7)
- # ring-swagger (3)
- # specter (33)
- # sql (2)
- # vim (21)
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}]])
@amacdougall if the attributes map is always the last element of the vector you can end with LAST
instead of [ALL map?]
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.
Thanks!
you can also use keypath
to navigate by index into a vector
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.
yea just takes practice
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]])
this is on specter 0.13.0. Specter 0.12.0 works just fine
@levitanong is this Clojure or ClojureScript? do you have a full stack trace?
clojurescript
hang on, will come up with the full stack trace
@levitanong what version of cljs?
1.9.225
I just pushed a build that renames that function, might fix it
try 0.13.1-SNAPSHOT
@nathanmarz Works perfectly, thanks 🙂
just upgraded to 0.13.0, started getting TypeError: this.$late1$.$select_STAR_$ is not a function
, looks like I didn’t include something?
relevant call-site: https://github.com/binaryage/dirac/blob/a95e9c3f42ca9cd202240509ecbc7196c3a19753/src/implant/dirac/implant/automation/reps.cljs#L63
I’m compiling my cljs code under :advanced with :pseudo-names true (running my tests against advanced mode build)
@darwin so you don't get the error under a different optimization mode?
trying to test that, but my project is pretty complex and I bumped into another issue with :none mode
also, you should try 0.13.1-SNAPSHOT
what version of cljs are you using?
so 0.13.1-SNAPSHOT behaves the same way for me under :advanced, now I’m going to make that :none mode work