Fork me on GitHub
#fulcro
<
2023-05-21
>
az18:05:43

Hi all. Not exactly a Fulcro question, but might just be something I'm missing as a setting. Data coming back from Pathom via transit has tagged literals, #f and #uuid, is there a way in Fulcro to convert this? Getting values like: #object[Transit$TaggedValue [TaggedValue: f, 10.000000000000000000000000000000]] Not sure how to render this to screen

az20:05:47

Got this working using the following. Is the the best method?

:response-middleware (http/wrap-fulcro-response 
                      (fn [r] r) 
                      {"f" f-tag-read-handler})

tony.kay06:05:33

No. Uuid float and such are built into transit. Did you set things up the way shown in book and templates? If you need a custom handle you can install it fulcro-wide as well. Seehttps://book.fulcrologic.com/#_custom_type_support

tony.kay15:05:27

f is for bigdecimal. That is handled automatically by transit itself. If you send a bigdecimal from the server, then you will get it on the client (as you should). If you’re using RAD then it comes with code the supports these in js (using Big.js), and the utilities I’ve written help you deal with them directly. See https://cljdoc.org/d/com.fulcrologic/fulcro-rad/1.0.7/api/com.fulcrologic.rad.type-support.decimal

az16:05:10

Thank you @U0CKQ19AQ, going to go back and see if I misconfigured somewhere. On the server I am using Pathom3. It's serving a different client, so I'm a bit stuck with v3. Not sure if that has something to do with it. I'm not using RAD yet, but plan on it once I have a better grasp of Fulcro

tony.kay16:05:50

I’m guessing everything is configured just fine

tony.kay16:05:20

it’s just that you’re getting the raw transit bigdecimal https://github.com/cognitect/transit-cljs#default-type-mapping

tony.kay16:05:19

even in RAD I leave them as cognitect representations. I just do calculations using big.js

tony.kay16:05:51

for example: https://github.com/fulcrologic/fulcro-rad/blob/fulcro-rad-1.0.7/src/main/com/fulcrologic/rad/type_support/decimal.cljc#L161 the math operators convert the ct bigdec into Big, then do math, then convert it back. So that the data rep in Fulcro is always the transit-compatible value.