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

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

Open
rutrum opened this issue Jul 30, 2020 · 4 comments
Open
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@rutrum
Copy link

rutrum commented Jul 30, 2020

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.

@MartinKavik
Copy link
Member

If I remember correctly, you are not the first one who suggested this change and I think it's a good idea. The type alias was inspired by the Elm Counter / Buttons.

However together with the change in this repo we should update the example and related docs also in:

@rutrum Do you want to update it? I would be very thankful.

@MartinKavik
Copy link
Member

Related issue: seed-rs/seed-rs.org#57

@zakaluka
Copy link
Contributor

zakaluka commented Apr 3, 2021

@MartinKavik The 3 referenced areas have been updated. However, there is (at least) one separate page on the website for the Model that I haven't updated yet. Will take a shot at it shortly.

@MartinKavik
Copy link
Member

@zakaluka Good job! It looks like the main Seed README is the last one to change - do you want to update it too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants