In Iced, we have our primary Application
struct. Conceptually, this is where I like to delegate my UI event handlers. That is, all events that directly affect or are affected by the UI. What about non-blocking work?
Suppose I have an expensive function I want to run called think
. I would like think
to not block the application while it’s running. The flow would look something like this.
- User clicks
think
button - Application broadcasts a
think clicked
event of some kind - Application recognizes the event, handles it by spinning up a separate thread
T
or something T
eventually finishes thinking function, and broadcasts the result back to the Application- Application picks up the finished event with the data, and updates the Application state accordingly
I have spent the past few days working with Iced’s Subscriptions
to try to work with this, but haven’t made much progress. Does Iced support this sort of behavior easily?
Thanks.