Allow Component::State to be initialized. #1475
edfloreshz
started this conversation in
Ideas
Replies: 2 comments 3 replies
-
why initialization is needed when there is a Default for the state. Well, if state initialization is needed, then it's better to do it as create_state with a default implementation that will return the default state. |
Beta Was this translation helpful? Give feedback.
3 replies
-
Linking the discord discussion here: The consensus appears to be a no. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Iced does not currently allow to initialize the state of a component, it might be useful to have a method that runs the first time the component is initialized.
I propose something like this to be implemented:
It would allow for things like this:
Preventing the value from being reset when the component is re-rendered and allowing for state to be initialized without having to do weird tricks in the
view
andupdate
method.Current implementation of this already exists in Frui, here's an example.
Beta Was this translation helpful? Give feedback.
All reactions