From a25b1af45690bdd8e1cbb20ee3a5b1c4342de455 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 14 Jun 2024 01:47:39 +0200 Subject: Replace `Command` with a new `Task` API with chain support --- examples/pokedex/src/main.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'examples/pokedex/src/main.rs') 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 { - Command::perform(Pokemon::search(), Message::PokemonFound) + fn search() -> Task { + 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 { + fn update(&mut self, message: Message) -> Task { 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; -- cgit