docs(mix_generator): record @MixWidget variant constructor decisions - #1000
Merged
Conversation
Capture why variant constructors take the shape they do, so a future simplification pass re-derives from the record instead of the code. Settled: the unnamed constructor stays alongside the generated named ones, because a variant selected from state or config cannot pick a constructor at compile time; no runtime variant API belongs in mix, because registering every enum value builds N styles per rebuild where the parameter form builds one; and the variant enum needs no EnumVariant mixin, since the value is only a switch key inside the recipe. Also records the decision to remove factoryParameters and rename widgetParameters to targetParameters, with the costs accepted and the one outstanding input noted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue
Closes out the design questions raised in #998 and PR #999. No code changes.
Description
Adds
guides/mix-widget-variant-constructors.md, a decision record for how@MixWidgetgenerates enum variant constructors and why it takes that shape.The feature itself already ships in
mix_generator 2.2.0-beta.2(added in #968).Nothing here changes behavior — this captures the reasoning so a future
simplification pass re-derives from the record instead of guessing from the code.
Decisions recorded
The unnamed constructor stays alongside the generated named constructors.
#998 asked for named-only widgets; declined. A variant that comes from state,
config, or a UI control cannot select a constructor at compile time, so
named-only forces those call sites to abandon the generated wrapper and rebuild
the style by hand. Remix measured 16 such sites in their own migration.
No runtime variant API belongs in
mix. #999's first implementation addedvariantsFromEnumandapplyVariant, which made the recipe return a stylecarrying every enum value for the widget to narrow down — building N styles per
rebuild and discarding N-1. The parameter form already builds exactly one, and
gets compile-time exhaustiveness from
switchrather than a runtime throw.The variant enum needs no
EnumVariantmixin. On this path the value is onlya
switchkey inside the recipe and never enters Mix's variant system. Recordedexplicitly, with a do-not-add note, because the rejected design did require it.
Also records rejected alternatives (convention-based enum discovery, a
@MixWidgetVariantmarker, per-value constructor selection) with the reason eachwas rejected, and the decision to remove
factoryParametersand renamewidgetParameterstotargetParametersin a follow-up — including the costsaccepted and the one outstanding input.
Review Checklist