Fork me on GitHub
#specter
<
2018-10-30
>
schmee07:10:16

is there a better way to construct this path? maybe something involving recursive-path?

(defn tag-path [& tag-names]
  (apply
    concat
    (interpose
      [ALL]
      (map
        #(vector (selected? :tag (pred= %)) :value)
        tag-names))))

schmee07:10:11

(tag-path "EA" "C1") => [(selected? :tag (pred= "EA")) :value ALL (selected? :tag (pred= "C1")) :value]

nathanmarz12:10:48

@schmee dynamic navs will dramatically increase performance when tag-path is called with dynamic params (eg. a local variable)

nathanmarz12:10:52

(defdynamicnav tag-path [& tag-names]
  (let [late-pred= (late-resolved-fn pred=)]
    (apply
      concat
      (interpose
        [ALL]
        (map
          #(vector (selected? :tag (late-pred= %)) :value)
          tag-names)
          ))))

nathanmarz12:10:51

things like this are where you get huge speedup:

(defn f [a data]
  (select (tag-path a "b") data)
  )

schmee12:10:15

nice! I haven’t delved into dynamic navs yet, I’ll check them out!

schmee12:10:31

but would you say that is an OK way to write the tag-path function?

schmee12:10:52

with all the interpose and apply and whatnot…

nathanmarz12:10:10

yes, it's fine

nathanmarz12:10:23

all that logic only ever executes once per callsite

nathanmarz12:10:26

because of dynamicnav

schmee12:10:47

excellent, thanks for the help as always

nathanmarz13:10:49

you've now delved into the most advanced part of specter ;)

nathanmarz13:10:59

let me know if you have questions

schmee21:10:54

is there any way to get access to collected values in view?

nathanmarz22:10:19

@schmee no, but it's easy to make a custom navigator with that functionality

nathanmarz22:10:23

see defrichnav

schmee22:10:49

:thumbsup: