Fork me on GitHub

How do I handle a com.cognitect.transit.URI type on the client side. In my db I can see the attribute value is

[TaggedValue: r, ]

Chris O’Donnell13:03:56

There's an example of wiring up a custom transit handler at the end of this blog post, too, if it helps.

❤️ 3
Chris O’Donnell13:03:01

In your case I think you would need to choose your own tag, like "uri", rather than override an existing one.


So, if you study what I do for BigDecimal in RAD: I use the transit type so that I can keep accuracy on numbers. I suggest you do a similar thing for URI perhaps? There is support in Fulcro for installing a custom handler easily that affects everything now, including http, websockets, and even transit-clj->str. I think you can override an existing type if you want. I did that because my suggestion is as follows: If you have a type you really store in a database on the server, then it should work isomorphically on the client. Network, forms, etc. as that type. So, there is a URI data type in CLJS. Install a handler for transit that decodes it to the client that way, and then if you were to use it in forms make a custom field type that can work with that data type (pull the string out for editing, enforce format, etc.). This also let’s you use the data type on the client fully.


and a sample usage that sets up tempid support is just below that.


If you put a transit type into a data transfer back to the server, of course that will transmit correctly, so you could also simply use the .-rep field of the transit type to work with it directly.


Thanks all for these suggestions. I will let you know how I go…


If I follow the example in the docs here, where is the best place to call install! ?


After the app is mounted?


Before? The lifecycle here isn’t clear to me.


client-will-mount of the app?


I can install the type-handlers and everything seems to be working fine. Only slightly weird thing is how the field is displayed in Fulcro Inspect. It looks like this now


Without the handler, it looks like this, but doesn’t work correctly.


How do I read this as a string, or store it as a string before it goes into the database.