-
Notifications
You must be signed in to change notification settings - Fork 108
Update templates #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update templates #362
Conversation
class $LayoutRunnerName( | ||
private val binding: ${ViewBindingName} | ||
) : LayoutRunner<${RenderingName}> { | ||
class ${NAME}( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LMK if there is a preference on camel case vs screaming snake case
data class Props | ||
data class State | ||
data class Output | ||
data class Rendering |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the part where it gets trickier as suggesting this pattern of internal data classes is a goal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how complex you want it to get, but there could be an option to leave the template blank for at type and then these would be generated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool. Didn't know about the internal pattern. I'll experiment with an if --> auto generate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok @steve-the-edwards I think I have it working. If you leave an "optional" field blank then it will auto generate inner class (and import)
fileTemplates/Stateful Workflow.kt
Outdated
props: ${PROPS_TYPE}, | ||
state: ${STATE_TYPE}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renderProps
and renderState
parameters are the new API and should be maintained.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 will revert.
My copy of render() (from com.squareup.workflow1:workflow-core-jvm:1.0.0-alpha.7) still shows props/state
fileTemplates/Stateless Workflow.kt
Outdated
renderProps: Props, | ||
context: RenderContext | ||
): Rendering { | ||
props: ${PROPS_TYPE}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again renderProps
is the new API.
We don't always want state/props/rendering/output to have the same name as the workflow. Nor do we always want to create those states/props/renderings/output. Sometimes those classes already exist (e.g. Unit, Nothing, Any).
LGTM. @steve-the-edwards, you good? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks very much for this @tir38 . Very sorry for the delay in reviewing!
IMO these templates would be more helpful if they let users set types in the creation dialog, not with a later refactor.
We don't always want state/props/rendering/output to have the same name as the workflow. Nor
do we always want to create those states/props/renderings/output. Sometimes those classes already
exist (e.g. Unit, Nothing, Any).
Stateful and Stateless Workflow templates now take in optional props/state/rendering/output. If these are left blank they will be auto created
Test
StatefulWorkflow Template
optionals left blank
generates:
optionals supplied
generates:
StatelessWorkflow template
optionals left blank
generates:
optionals supplied
generates:
LayoutRunner template
generates: