Skip to content
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

Modernize tutorial final code #1116

Closed
wants to merge 3 commits into from
Closed

Conversation

rjrjr
Copy link
Contributor

@rjrjr rjrjr commented Oct 12, 2023

There are a lot of indentation changes here, good idea to hide whitespace while reviewing.

It's time to get the Tutorial caught up with undeprecated API. This PR modifies only the final tutorial module. Once we're happy with the code, I'll back port the changes and update the prose in follow ups.

  • Use AndroidScreen and drop ViewRegistry
  • Use View.setBackHandler
  • Use TextController
  • More consistent naming, code style for actions and event handlers in Screen renderings

I did not introduce RenderContext.eventHandler {}, that seems like it would just be confusing to a newcomer.

Also not introducing big new blocks of material, in particular not introducing Overlay. I do think we should do that, but for this release I just want to focus on getting the deprecated code deleted.

@rjrjr rjrjr force-pushed the ray/fresh-tutorials branch 4 times, most recently from 684b931 to fe04b90 Compare October 12, 2023 21:53
@rjrjr rjrjr marked this pull request as ready for review October 12, 2023 21:53
@rjrjr rjrjr requested review from zach-klippenstein and a team as code owners October 12, 2023 21:53
@rjrjr rjrjr changed the base branch from main to ray/tutorial-update October 12, 2023 21:57
@rjrjr rjrjr force-pushed the ray/fresh-tutorials branch 2 times, most recently from 6b66f94 to 36bcfe6 Compare October 13, 2023 18:57
}

private fun onDiscard() = action {
private val postDiscard = action {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not understanding where the 'post' namign is coming from? I think i get that we are 'posting' either a discard or a save to our parent Workflow? Is that the intention?
I'm not sure that's helpful to me though as the name of the action.

LIke is the action about what it does (posting a save) or what it responds to (on "Save" clicked)? I feel like we've often used the latter, so maybe that's what is tripping me up. Maybe the former is preferrable?

Maybe this is all pedantic (though if there's any place to be so, it would be the tutorial...).

I, for one, long for Action suffixes when we save actions like this. As in could we use discardAction, saveAction -> telling you what it is (Action) and what it does (discard or save) but not the implementation details ('posting' to the parent).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LIke is the action about what it does (posting a save) or what it responds to (on "Save" clicked)? I feel like we've often used the latter, so maybe that's what is tripping me up. Maybe the former is preferrable?

I like the *Action notion, will adopt.

Copy link
Contributor Author

@rjrjr rjrjr Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually…

What I liked about the awkward post* names was that they communicated what was going to happen in response to the UI event. I don't think that's an implementation detail, it helps make visible what the role of this workflow is in the overall structure. And once I've put the names in that very active format, the *Action suffix starts to sound noisy.

WDYT:

      onTodoSelected = { context.actionSink.send(requestSelection(it)) },
      onBackPressed = { context.actionSink.send(requestGoBack) },
      onAddPressed = { context.actionSink.send(requestNew) }

)
}

private fun onBack() = action {
private val postGoBack = action {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comments.

title: String,
note: String
) : this(TextController(title), TextController(note))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this used directly in the rendering?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. That's the normal pattern for TextController, which is why I've pushed back when anyone talks about generalizing it.

@rjrjr rjrjr force-pushed the ray/fresh-tutorials branch from 36bcfe6 to 506d00f Compare October 13, 2023 21:59
rjrjr added 2 commits October 24, 2023 13:20
It's time to get the Tutorial caught up with undeprecated API. This PR modifies only the final tutorial module. Once we're happy with the code, I'll back port the changes and update the prose in follow ups.

- Use `AndroidScreen` and drop `ViewRegistry`
- Use `View.setBackHandler`
- Use `TextController`
- More consistent naming, code style for actions and event handlers in `Screen` renderings

I did not introduce `RenderContext.eventHandler {}`, that seems like it would just be confusing to a newcomer.

Also not introducing big new blocks of material, in particular not introducing `Overlay`. I do think we should do that, but for this release I just want to focus on getting the deprecated code deleted.
@rjrjr rjrjr force-pushed the ray/fresh-tutorials branch from 8ff126f to 79a66f9 Compare October 24, 2023 20:23
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@rjrjr rjrjr deleted the branch ray/tutorial-update October 26, 2023 16:20
@rjrjr rjrjr closed this Oct 26, 2023
@rjrjr rjrjr deleted the ray/fresh-tutorials branch December 12, 2023 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants