Skip to content

Understanding widget operations #1829

Closed Answered by hecrj
lufte asked this question in Q&A
May 4, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Widget operations are side effects of the update logic. Similar to a Command that runs some Future.

iced is inspired by Elm, a pure functional language. As a result, iced follows the Elm Architecture, which exposes side effects as a first-class concept.

Even if we changed the architecture, operations work on the widget tree and we will always be forced to either returning them or providing a new argument to record them.

And even if we wanted to offer a way to execute operations in update logic itself, this is not possible because operations operate on the result of view and view borrows self but update mutates self. Because of the borrow rules, update can never access the result of view d…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@lufte
Comment options

Answer selected by lufte
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants