fix: add run_with(Example::new)

The example was not running the `update` method and was stuck on the loading screen (at least on macos). This fixes is on my system.
This commit is contained in:
Osma S. Rautila 2024-12-01 15:31:27 +02:00 committed by Héctor Ramón Jiménez
parent 3b2a422d5d
commit 334f5baa10
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -7,7 +7,7 @@ pub fn main() -> iced::Result {
Example::update, Example::update,
Example::view, Example::view,
) )
.run() .run_with(Example::new)
} }
#[derive(Default)] #[derive(Default)]
@ -28,6 +28,10 @@ enum Message {
} }
impl Example { impl Example {
fn new() -> (Self, Task<Message>) {
(Self::Loading, Task::done(Message::Refresh))
}
fn update(&mut self, message: Message) -> Task<Message> { fn update(&mut self, message: Message) -> Task<Message> {
match message { match message {
Message::Refresh => { Message::Refresh => {