Organization of various states in the program #2050
Replies: 1 comment
-
Hi @aadityadhruv ! I'm coming here for a similar issue, going off the doc's example of a mulit-view app, the iced/examples/tour/src/main.rs Lines 99 to 104 in 817f728 ... iced/examples/tour/src/main.rs Lines 213 to 228 in 817f728 and then a pile of if let STEP1 = self nested inside of a matchiced/examples/tour/src/main.rs Lines 231 to 243 in 817f728 This approach (or better yet making a new enum for each state, injected as a variant of the StepMessages which is itself in Message ) is sustainable for medium scale projects.
From what I have been able to make out there is no way of making Invalid States Unrepresentable with StateMachines and Transitions (because It would be nice to have a way to define messages per state, but that's not able to be done at the moment. Below is a snip of my current match on my pet project. |
Beta Was this translation helpful? Give feedback.
-
I'm currently building an application to learn iced and advance my knowledge of rust. Right now, my program is structured such that I have a root struct which stores the states of everything, as such:
Currently I have 3 "screens" which I switch the
ScreenStruct
field in Process, and the view changes based on that field since I have amatch
statement for that.I also have a bunch of text input boxes in one of the screens, and for each of those text inputs I need to add an
Message
enum and a state to store the value of the text input.This is making my state struct grow large. I also don't know if the
match
statement in theview
method is the correct way to handle different screens.Any advice on solving these issues would be appreciated!
Beta Was this translation helpful? Give feedback.
All reactions