You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm playing a bit of catch up on the changes for single fetch and have a question relating to turbo-stream.
First a bit of context:
We've use Zod for our internal data models and anything that's sent over the wire. We've also standardised on Luxon DateTime and BigNumber so we rarely see a JS Date or JS Number in our code which gets around various deficiencies in their implementations. We created wrappers around the various remix utils related to fetchers and loader data that parsed using zod so our loaders etc were fully type-safe and the serialization / deserialization of objects into json containing DateTime and BigNumber "just worked". For a while we used superjson which achieved the same kind of thing.
Both of these libraries allow the configuration of "transformers" in their own way, similar to what is done with turbo-stream, but it could work for any datatype. I see that turbo-stream has a concept of plugins which appears to do this but I can't find any mechanism for configuring this in Remix. The turbs-stream implementation requires the plugins to be passed to encode and decode directly which is called by Remix. It'd be great if we could globally register a plugin against a type for turbo-stream to use.
Our workaround for this is to continue to serialize to json and parse as we have but it would be ideal if we could avoid this double parsing and just let turbo-stream do this for us.
Is there a plan to expose this capability - or better still, does it already exist and I've just missed it?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm playing a bit of catch up on the changes for single fetch and have a question relating to turbo-stream.
First a bit of context:
We've use Zod for our internal data models and anything that's sent over the wire. We've also standardised on Luxon DateTime and BigNumber so we rarely see a JS Date or JS Number in our code which gets around various deficiencies in their implementations. We created wrappers around the various remix utils related to fetchers and loader data that parsed using zod so our loaders etc were fully type-safe and the serialization / deserialization of objects into json containing DateTime and BigNumber "just worked". For a while we used superjson which achieved the same kind of thing.
Both of these libraries allow the configuration of "transformers" in their own way, similar to what is done with turbo-stream, but it could work for any datatype. I see that turbo-stream has a concept of plugins which appears to do this but I can't find any mechanism for configuring this in Remix. The turbs-stream implementation requires the plugins to be passed to encode and decode directly which is called by Remix. It'd be great if we could globally register a plugin against a type for turbo-stream to use.
Our workaround for this is to continue to serialize to json and parse as we have but it would be ideal if we could avoid this double parsing and just let turbo-stream do this for us.
Is there a plan to expose this capability - or better still, does it already exist and I've just missed it?
Beta Was this translation helpful? Give feedback.
All reactions