diff options
author | 2024-06-16 20:24:41 +0200 | |
---|---|---|
committer | 2024-06-16 20:24:41 +0200 | |
commit | 95d4adb55e485c01eec839736f328be26f2ccab6 (patch) | |
tree | 2676e3cb8ec17c5bf1cd561d97932ae302551dfd /examples/pokedex | |
parent | e6d0b3bda5042a1017a5944a5227c97e0ed6caf9 (diff) | |
parent | b5c5a016c4f2b608a740b37c494186557a064f48 (diff) | |
download | iced-95d4adb55e485c01eec839736f328be26f2ccab6.tar.gz iced-95d4adb55e485c01eec839736f328be26f2ccab6.tar.bz2 iced-95d4adb55e485c01eec839736f328be26f2ccab6.zip |
Merge pull request #2463 from iced-rs/task-api
`Task` API
Diffstat (limited to 'examples/pokedex')
-rw-r--r-- | examples/pokedex/src/main.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/examples/pokedex/src/main.rs b/examples/pokedex/src/main.rs index cffa3727..e62ed70b 100644 --- a/examples/pokedex/src/main.rs +++ b/examples/pokedex/src/main.rs @@ -1,6 +1,6 @@ use iced::futures; use iced::widget::{self, center, column, image, row, text}; -use iced::{Alignment, Command, Element, Length}; +use iced::{Alignment, Element, Length, Task}; pub fn main() -> iced::Result { iced::program(Pokedex::title, Pokedex::update, Pokedex::view) @@ -25,8 +25,8 @@ enum Message { } impl Pokedex { - fn search() -> Command<Message> { - Command::perform(Pokemon::search(), Message::PokemonFound) + fn search() -> Task<Message> { + Task::perform(Pokemon::search(), Message::PokemonFound) } fn title(&self) -> String { @@ -39,20 +39,20 @@ impl Pokedex { format!("{subtitle} - Pokédex") } - fn update(&mut self, message: Message) -> Command<Message> { + fn update(&mut self, message: Message) -> Task<Message> { match message { Message::PokemonFound(Ok(pokemon)) => { *self = Pokedex::Loaded { pokemon }; - Command::none() + Task::none() } Message::PokemonFound(Err(_error)) => { *self = Pokedex::Errored; - Command::none() + Task::none() } Message::Search => match self { - Pokedex::Loading => Command::none(), + Pokedex::Loading => Task::none(), _ => { *self = Pokedex::Loading; |