Remix.run Logo
lpil 10 hours ago

You can generate those conversions, most people do.

But also, you shouldn’t think of it as writing the same type twice! If you couple your external API and your internal data model you are greatly restricting your domain modelling cability. Even in languages where JSON serialisation works with reflection I would recommend having a distinct definition for the internal and external structure so you can have the optimal structure for each context, dodging the “lowest common decimator” problem.

miki123211 10 hours ago | parent | next [-]

I understand your point, and I agree with it in most contexts! However, for the specific use case where one assumes that the client and server are running the exact same code (and the client auto-refreshes if this isn't the case), and where serialization is only used for synchronizing between the two, decoupling the state from it's representation on the wire doesn't really make sense.

lpil 9 hours ago | parent [-]

Totally. This is where I would generate them.

premek 8 hours ago | parent | prev [-]

>You can generate those conversions, most people do.

Hi, what do people use to generate them, I found gserde (edit: and glerd-json)

okkdev 6 hours ago | parent [-]

The language server code action :)