Construct props using builder pattern #2073
MuhannadAlrusayni
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem
I'm exploring the possibility to have DSL working with Yew so someone can build the view using only DSL without using
JSX
style/syntax, something similar to this:This is an imaginary syntax to give an example on how DSL view might look like. I believe there is many blockers to have this functionality in today Yew.
One blocker I find is the ability to set optional props without using
html!/props!
macro, in current Yew we can createProps
using theProps::builder
function found inProperties
trait that would returnPropsBuilder<T, PropsBuilderStep_missing_required_prop_PROP_NAME>
, the issue is that optional props setters implementation are separated acrossPropsBuilder<T, STEPS>
for example if component have these props:the output would look like:
There are two issue with this:
1- As we can see
id
andhelp
setters are attached toPropsBuilderStep_missing_required_prop_label
step, these setters should be available on all steps.2- the second thing is that when I want to set the
path
prop I cannot do that before I set the value forid
.So doing this will result in compile time error:
error:
Environment:
master
Questionnaire
Beta Was this translation helpful? Give feedback.
All reactions