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))))
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
Might need to provide a custom version of that fn for sci that can check this type and do the default thing maybe 🤔
is there a #?(:sci ...) form? if not I guess I could do something like #?(:cljs (and (object? x) (number? (.code x))))
I think I added a :portal one that might be useful here
that's close enough for my purposes; I'm just trying to tell apart strings, vectors, maps and chars.
ah, that would work.
there's a weird inconsistency here. if I
(p/eval-str "\\c") I get "c", ie. a 1-length string in CLJS fashion.
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.
I see 🤔
Ok, I think you want (or (char? "c") (portal.ui.inspector/char?
that seems to be working behind the #?(:portal ...) conditional.