Skip to content

Change type Model = i32 to struct Model { counter: i32 } in App 1: Counter #29

@rutrum

Description

@rutrum

I think using this pattern doesn't make it obvious for how users might expand on the example. If a user does decide to use a struct as their model, the code written in update and view also need to updated, while not always obvious. For example, a user might try to do this:

struct Model {
    name: String,
}
fn view(model: &Model) -> Node<Msg> {
    div![
        button![model],
    ]
}

...and not realize that you can't use model in this way as you could when it was a type alias. I think more modular the first example is the best it is for the user experience.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions