fastify-dx icon indicating copy to clipboard operation
fastify-dx copied to clipboard

Revise URMA Rendering Options

Open reconbot opened this issue 2 years ago • 5 comments

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

I was reading the rendering options and was wondering if they were exclusive of eachother? And if so maybe they should be a string union or enum?

Motivation

Prevents impossible states from happening.

Example

interface RouteModule {
  renderingMode?: 'server' | 'client' | 'isomorphic' // default is isomophic
  streaming?: boolean
  generated?: boolean // I noticed this wasn't documented
}

reconbot avatar Jun 25 '22 12:06 reconbot

Hey there! Yeah, I thought about using an enum but I feel setting flags to booleans is more developer friendly than assigning strings to a single property? Maybe it's just me, just a perception — but it might be the case that we have a mode property as an alternative to the boolean flags? WDYT?

galvez avatar Jun 25 '22 13:06 galvez

The generated flag is for SSG, which I'm adding support for in the next cycle.

galvez avatar Jun 25 '22 14:06 galvez

I think with typescript or js with an editor that understands types it's really easy to autocomplete the strings and typecheck if you make a typo etc.

I think having both is a bad idea for the same reasons having having multiple booleans that represent the same thing is a bad idea. It's possible to represent a bad state even if you typecheck.

I was on the fence if "streaming" is part of "renderingMode" because I'm not sure if "streaming" is relevant for client side rendering or not. (I think it is or could be one day?)

reconbot avatar Jun 25 '22 14:06 reconbot

You do make a compelling argument, sir. I'm tempted to make this change for 0.3 onwards.

galvez avatar Jun 25 '22 14:06 galvez

+1 on this. I came here to say exactly the same. It's also much easier to reason at a glance how a route would be rendered!

dac09 avatar Jul 04 '22 22:07 dac09