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

Can this support states of child components? #29

Closed
matthunz opened this issue Jan 1, 2023 · 4 comments
Closed

Can this support states of child components? #29

matthunz opened this issue Jan 1, 2023 · 4 comments

Comments

@matthunz
Copy link
Contributor

matthunz commented Jan 1, 2023

For example, if a button has a boolean state of pressed and I have a lot of them, do they have to become part of the global state now?

If so I think some way of combining the data tree with the widget tree could make this more flexible

@matthunz matthunz closed this as completed Jan 1, 2023
@matthunz
Copy link
Contributor Author

matthunz commented Jan 1, 2023

It would be very limiting to have a single “app state” type throughout the application, and require all callbacks to express their state mutations in terms of that global type. So we won’t do that.

Nevermind this was explained in the blog post!

@matthunz matthunz reopened this Jan 1, 2023
@matthunz
Copy link
Contributor Author

matthunz commented Jan 2, 2023

Actually the more I read into it it seems a global state is required, the Adapt node will just help to map it.

My concern is that for components like buttons we would now need to track their state globally. For example a button that tracks when it's hovered may have internal state to change it's background color.

@matthunz
Copy link
Contributor Author

matthunz commented Jan 2, 2023

If that's the case we could an 'IntoView' trait and have a 'Button' be in the global state so that we can can call 'into_view' on it

@Zoxc
Copy link
Collaborator

Zoxc commented Jan 2, 2023

Both views and widgets can have internal state. There's also the UseState view which can create internal state without a custom view implementation, but it's a bit more awkward due to its Arc requirement.

@matthunz matthunz closed this as completed Jan 3, 2023
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

No branches or pull requests

2 participants