Replies: 3 comments
-
The Elm architechture generally has long files, that is intentional. ( See 1 & 2 ). Because of that I dont see your requested change happening to iced. I would also recommend you try the longer file method typical of the elm architechture, but if you decide not to, there is no reason that you cant have your |
Beta Was this translation helpful? Give feedback.
-
The "Culture Shock" section of the Elm guide warns against this:
State, messages, update, and view logic are all tightly coupled together and part of the same abstraction. Every module in Rust is like a small library. It makes no sense to have a module that only exposes an incomplete abstraction! |
Beta Was this translation helpful? Give feedback.
-
Thanks for your prompt replies and inspirational references, I'll reconsider all this myself. |
Beta Was this translation helpful? Give feedback.
-
First of all thank you for developing this awesome project, a good Rust GUI library was what I missed the most, finally I found one that I really like!
I would like to propose a suggested crate layout for Iced apps, which further enforces separation of the four Iced fundamental entities state / message / update / view, by splitting them into different modules and files. I find this way much more practical to implement non-trivial Iced apps, because instead of scrolling a single long file I just swap between tabs of my code editor to update the four entities as needed.
Of course anyone can come up to this crate layout autonomously by applying basic Rust programming best practices, but IMHO it would be useful to many people addressing Iced for the first time to get an example coded with separate modules, at least to pop the idea into their mind and better consider how to structure their next Iced project.
Here is my sample implementation, which maybe could be further improved, and I could PR among the Iced examples if you agree:
main.rs
iced_state.rs
iced_message.rs
iced_update.rs
iced_view.rs
Beta Was this translation helpful? Give feedback.
All reactions