Skip to content

chore: improve counter example - #3264

Closed
janTatesa wants to merge 1 commit into
iced-rs:masterfrom
janTatesa:simplify_counter_example
Closed

chore: improve counter example#3264
janTatesa wants to merge 1 commit into
iced-rs:masterfrom
janTatesa:simplify_counter_example

Conversation

@janTatesa

Copy link
Copy Markdown
Contributor

This pr:

  • Changes formatting in update
  • Centers the ui

@hecrj hecrj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think these changes are necessarily an improvement.

@hecrj hecrj closed this Mar 11, 2026
@hecrj hecrj added this to the 0.15 milestone Mar 11, 2026
@hecrj hecrj added the improvement An internal improvement label Mar 11, 2026
@janTatesa

Copy link
Copy Markdown
Contributor Author

Why aren't they? Container is arguably the second most used widget after text, so I think it's suitable for the first example one looks at. When it comes to formatting can you elaborate? I mean the change clearly simplifies it

@hecrj

hecrj commented Mar 12, 2026

Copy link
Copy Markdown
Member

Are you asking in good faith because you are genuinely curious? Or will you silently disagree when I provide an explanation?

If it's the former, then what do you think my concerns could be? What could be the reasons I don't like container used in the counter example? And why do I not like the one-liners in update?

Can you think of anything?

@janTatesa

Copy link
Copy Markdown
Contributor Author

In terms of container, I think you're trying to say that counter example should be as simple as possible. But I think the goal should be to introduce people to the library, which I think should involve one of the first elements they are going to use in their first app, which container will certainly. In terms of formatting I completely have no idea. Maybe that adding lines to non one liners is faster?

@hecrj

hecrj commented Mar 12, 2026

Copy link
Copy Markdown
Member

You are looking at it in a very short-sighted way.

But I think the goal should be to introduce people to the library, which I think should involve one of the first elements they are going to use in their first app

The counter example is the example we use to introduce the basics of the library in the overview and the book. The goal is to introduce the Elm Architecture. Layout is secondary here. column is already enough to introduce basic layout principles in a very natural way because the example organically needs it.

container just adds unnecessary noise. There are plenty of other examples that use it.

Maybe that adding lines to non one liners is faster?

Shorter does not mean simpler. Relying on the fact that += returns () is obscure, and may create the false notion that update handlers must be one-liners.

I've put quite some thought on this. I am even writing a book about it.

@janTatesa

Copy link
Copy Markdown
Contributor Author

Okay makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement An internal improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants