I just attempted to write up a simple Minesweeper game with Iced. No bells or whistles, but it works:
https://github.com/veniamin-ilmer/minesweeper
On one hand, I find it pretty cool I built a clear cross platform GUI with actual functionality, within only 200 lines of code.
On the other hand, I can’t help but see how inefficient it seems. If I ever need to modify any of the objects, I need to redraw all of them. The structure of the view
method makes me think it is very difficult for Iced to maintain a “virtual DOM” to only make delta changes.
Am I wrong? Is there a more efficient way to do this in Iced?
Edit: I just found this - https://github.com/iced-rs/iced/pull/1284
As the library matures, the need for some kind of persistent widget data (see #553) between view calls becomes more apparent (e.g. incremental rendering, animations, accessibility, etc.).
If we are going to end up having persistent widget data anyways… There is no reason to have impure, stateful widgets anymore!
So it seems like Iced plans to have an internal “persistent widget storage”, which in abstracted away from the user. But it is quite unclear to me how they would accomplish this, considering the view
method doesn’t provide an ID for any of its objects, so it would not be easy for Iced to determine the difference between updates.
That’s been resolved by cosmic-text, which is being used by iced now. The cosmic-text crate provides a text editing widget, too.
Is it actually ready to use? I don’t see much information about how to use it. I know there’s been work on integrating cosmic-text, but I notice this issue is still open: https://github.com/iced-rs/iced/issues/320