Fork me on GitHub
#specter
<
2021-02-20
>
mrchance09:02:33

Hi, I'm trying to use specter in cljs, but I can't get it to work. Even for examples from the tutorial, I get:

(setval {:a [1 2 3]} [:a s/END] [4 5])
Error: No protocol method ImplicitNav.implicit-nav defined for type cljs.core/PersistentArrayMap: {:a [1 2 3]}
Am I doing something wrong?

Jeff Evans13:02:50

Looks like you did not require the namespace properly

mrchance17:02:04

I did require [com.rpl.specter :as s :refer-macros [setval]] , do I need more?

Jeff Evans17:02:27

I think you don't want to use refer-macros. Use prefix qualification for setval. CLJS doesn't have access to macros at runtime.

mrchance20:02:58

Hm, thanks for the support, I looked into it, but I don't think that's it, that's more or less exactly the line recommended in the spectre README... https://github.com/redplanetlabs/specter#clojurescript

Jeff Evans20:02:57

Oh actually, different problem. There is no implicit navigator for maps like that. Not sure where your snippet came from but it's not a valid navigator. See, ex: https://github.com/redplanetlabs/specter/pull/292

mrchance20:02:58

The example is also taken verbatim from the readme... Maybe you could explain a bit how implicit navigators work and what they're needed for? I thought my path was pretty explicit :D

mrchance20:02:51

Oh, nvm, I messed up the order 🙈

Jeff Evans20:02:57

I don't see that in the readme

mrchance20:02:58

You're right, that's just wrong

mrchance20:02:09

(setval [:a END] [4 5] data)
That's the example

mrchance20:02:41

Turns out, if you do it correctly, it works! Who would've thought. Thank you for pointing it out, not sure how I overlooked that, stared at the line several times. Probably not having a good day 😅

Jeff Evans20:02:07

It happens :man-shrugging:

thanks3 1