Replies: 1 comment 2 replies
-
Suggestions from @francoistanguay CounterModel
IState<Counter> Counter
IState<CountryModel> Country; would become CounterViewModel
CounterState?
CountryModelState? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Actual state
Let assume the sample:
Currently we will generate:
1. Root proxy
The class
BindableCounterModel
is generated in order to be used as the root data-context of a MVUX object model. Typically we expect it to be used asDataContext
of thePage
This will re-expose all properties exposed by the
CounterModel
(methods being converted asICommand
).Trigger
This generator triggers on
CounterModel
because:2. Sub proxy
The class
BindableCountable
is generated by what we could name a "entiy generator". The purpose of this generator is to de-normalize properties theCountable
to allow 2-way binding directly on each property (so for instance we can use a slider to set theStep
: ```).Classes generated by this generator are not expected to be used by end-users, they are instead expected to be referenced only by the code generated by the "root proxy" generator.
Trigger
This generator triggers on
Countable
because (and):record
IState
property by a class that triggered the first generator.The problems
Code gen
Countable
class "CountableModel", both "root" and "sub" proxies genertoir will trigger and will use the same filename / class name / namespace driving compilation to fail (cf. C# Markup + MVUX: More than one model named as <somethingModel> produces a source generator error. #2307 and [MVUX] Creating aState<XXXModel>
break code gen ifXXXModel
is arecord
#2310)Naming
We have confusion about what we call a "model". Currently it refers to both:
CounterModel
in our sampleCountable
in our sample.In doc to avoid confusion we choose to name the second "entity" to avoid confusion.
Proposal
Considering that
MyApp
MVUX.Updaters.MyApp
MyApp
MVUX.Models.MyApp
Also in order to reduce friction regarding custom namespace, the recommendation would be tu use inject in the updater a factory static method to create the
ViewModel
.Example
Same example as above with new naming:
And generated proxies:
Unknown
Beta Was this translation helpful? Give feedback.
All reactions