Reuse Pokedex search Command in update logic

This commit is contained in:
Héctor Ramón Jiménez 2024-03-16 15:56:10 +01:00
parent 93ae790da1
commit 3f81c524cc
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -4,7 +4,7 @@ use iced::{Alignment, Command, Element, Length};
pub fn main() -> iced::Result { pub fn main() -> iced::Result {
iced::application(Pokedex::title, Pokedex::update, Pokedex::view) iced::application(Pokedex::title, Pokedex::update, Pokedex::view)
.load(Pokedex::load) .load(Pokedex::search)
.run() .run()
} }
@ -25,7 +25,7 @@ enum Message {
} }
impl Pokedex { impl Pokedex {
fn load() -> Command<Message> { fn search() -> Command<Message> {
Command::perform(Pokemon::search(), Message::PokemonFound) Command::perform(Pokemon::search(), Message::PokemonFound)
} }
@ -56,7 +56,7 @@ impl Pokedex {
_ => { _ => {
*self = Pokedex::Loading; *self = Pokedex::Loading;
Command::perform(Pokemon::search(), Message::PokemonFound) Self::search()
} }
}, },
} }