Fork me on GitHub
#portal
<
2023-11-16
>
Braden Shepherdson03:11:22

I'm having an issue with sending \c char values to portal. they show up as a wrapped value something like pU {code: 40, P: 2153775104, aa: 0} in the devtools. 40 = ASCII for ( which is the character that's supposed to be. but that value does not pass char? called from a custom view. CLJS is expecting 1-length strings, (defn char? [x] (and (string? x) (== 1 (.-length x))))

djblue03:11:10

Ohh dang, I didn't even know that was a thing in cljs 😂 https://github.com/djblue/portal/blob/master/src/portal/runtime/cson.cljc#L277-L298 is how chars are represented in cljs

djblue03:11:50

Might need to provide a custom version of that fn for sci that can check this type and do the default thing maybe :thinking_face:

Braden Shepherdson03:11:16

is there a #?(:sci ...) form? if not I guess I could do something like #?(:cljs (and (object? x) (number? (.code x))))

djblue03:11:38

I think I added a :portal one that might be useful here

Braden Shepherdson03:11:43

that's close enough for my purposes; I'm just trying to tell apart strings, vectors, maps and chars.

Braden Shepherdson03:11:46

ah, that would work.

Braden Shepherdson03:11:53

there's a weird inconsistency here. if I (p/eval-str "\\c") I get "c", ie. a 1-length string in CLJS fashion.

Braden Shepherdson04:11:04

I guess p/eval-str is plain CLJS, while the values sent via tap> are sci values? but that means I can't write #?(:portal ...) in a ns required by my custom viewer and then p/eval-str it; that's :cljs.

djblue04:11:01

I see :thinking_face:

djblue04:11:40

Ok, I think you want (or (char? "c") (portal.ui.inspector/char? ))

Braden Shepherdson18:11:16

that seems to be working behind the #?(:portal ...) conditional.

awesome 1