Fork me on GitHub
#specter
<
2016-06-03
>
darwin12:06:55

hi, is recursive navigation supported under cljs in 0.11, I have troubles calling extend-protocolpath

darwin12:06:19

it complains Use of undeclared Var com.rpl.specter.impl/extend-protocolpath*

nathanmarz13:06:10

protocol paths don't work in clojurescript version

nathanmarz13:06:19

you can still do recursive navigation without protocol paths

darwin13:06:39

thanks, any pointer to some example? I’m pretty new to specter

nathanmarz13:06:46

the last example on the README

nathanmarz13:06:57

(declarepath TreeValues)

(providepath TreeValues
  (if-path vector?
    [ALL TreeValues]
    STAY
    ))

darwin13:06:19

it looks like insanely powerful tool when mastered btw. thanks a bunch!

nathanmarz13:06:04

(transform [TreeValues even?] - [[1 2] [[3] 4] [6 [8 9 10]]])
;; => [[1 -2] [[3] -4] [-6 [-8 9 -10]]]

darwin13:06:18

got it, going to take that route

nathanmarz13:06:32

also look at continue-then-stay and stay-then-continue for doing post-order or pre-order traversals

darwin13:06:00

I’m probably missing something, here is my current code, cannot make it work, want? predicate is never called according to that log statement, I call filter-rep and then pprint it to string, so possible laziness should NOT prevent those calls, https://gist.github.com/darwin/9a2673fdb2448132c6d1908195df0932

darwin13:06:00

I’d like to use specter as filter for filtering scraped DOM structure for my tests

nathanmarz13:06:00

yea, your path is incorrect

nathanmarz13:06:16

it only navigates you to elements of :children sequences that aren't maps

nathanmarz13:06:23

try this path:

nathanmarz13:06:08

(declarepath MyWalker)
(providepath MyWalker
  (continue-then-stay
    :children
    ALL
    MyWalker
    ))

nathanmarz13:06:32

that navigates you to every map

darwin13:06:44

thanks, that works

darwin13:06:47

what if I need to traverse down both into :children and/or :children2 if present

nathanmarz13:06:57

use multi-path + must

nathanmarz13:06:08

(declarepath MyWalker)
(providepath MyWalker
  (continue-then-stay
    (multi-path (must :children) (must :children2))
    ALL
    MyWalker
    ))

darwin13:06:23

looks good, thanks a lot

nathanmarz13:06:58

you can make it a little more concise like this:

(providepath MyWalker
  (continue-then-stay
    (multi-path
      [(must :children) ALL]
      (must :shadowRoot))
    MyWalker))

darwin13:06:46

cool! I have a feeling this will be a “jquery” on steroids 🙂

darwin15:06:21

getting some warnings when compiling specter’s impl namespace: https://gist.github.com/darwin/90bcb9a87d7f1b492cd6d6400bcd103c#file-impl-cljs-L3

darwin15:06:30

not sure about bootstrap, but cljs.js should be cljs.core in my case, I’m not in bootstrapped environment

nathanmarz15:06:32

You can ignore the warnings, and they're fixed for the next version: https://github.com/nathanmarz/specter/issues/97

nathanmarz15:06:53

They have to do with code that's specifically for bootstrap cljs

darwin15:06:37

ok, np, btw. I was searching open issues first and didn’t find anything related