What is the correct way to shutdown an initialized async program that needs deinitialization, starting from the cupertino_spinner example? #1812
Replies: 2 comments
-
The closest I got to doing this right is by subscribing to events, and handling the event |
Beta Was this translation helpful? Give feedback.
0 replies
-
I guess it works fine now. The fix was that |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First, let me thank you for the beautiful library and design. I really find it beautiful.
If you don't mind, I have a question regarding communication in a model-view-controller paradigm.
The cupertino_spinner example shows how to initialize a program into a struct (called State in the example, which I plan to make a controller). I have a program that works as a daemon and I'd like to initialize it in the GUI, and then use the data in State (from the cupertino_spinner example) to be able to communicate with the daemon. The State object contains the Controller part that will be able to send/receive data/events from the daemon to manipulate its state.
What I'm wondering is, currently the initialization of my program does some async stuff and needs to be shutdown manually on exit. Meaning, when the user decides to exit the GUI, one async function must be called and awaited, and we should wait for some time for the shutdown process to complete, and then the GUI is "free to exit".
Is there a way to do that in iced?
Previous attempts: Before finding out about the aforementioned spinner example, I did this initialization and shutdown manually by using an async main, and then using block_in_place in tokio to start iced event loop (since it must be in the main thread). Once that returns, the shutdown is called right after that. But then this is wrong because we cannot be in a "loading state" while the program is initializing.
Beta Was this translation helpful? Give feedback.
All reactions