Remove load method from application and daemon

If you need to run a `Task` during boot, use
`run_with` instead!
This commit is contained in:
Héctor Ramón Jiménez 2024-07-09 00:28:40 +02:00
parent 3d99da805d
commit e86920be5b
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
10 changed files with 70 additions and 197 deletions

View file

@ -16,7 +16,7 @@ version = "1.0"
features = ["derive"]
[dependencies.reqwest]
version = "0.11"
version = "0.12"
default-features = false
features = ["json", "rustls-tls"]

View file

@ -4,17 +4,13 @@ use iced::{Alignment, Element, Length, Task};
pub fn main() -> iced::Result {
iced::application(Pokedex::title, Pokedex::update, Pokedex::view)
.load(Pokedex::search)
.run()
.run_with(Pokedex::new)
}
#[derive(Debug, Default)]
#[derive(Debug)]
enum Pokedex {
#[default]
Loading,
Loaded {
pokemon: Pokemon,
},
Loaded { pokemon: Pokemon },
Errored,
}
@ -25,6 +21,10 @@ enum Message {
}
impl Pokedex {
fn new() -> (Self, Task<Message>) {
(Self::Loading, Self::search())
}
fn search() -> Task<Message> {
Task::perform(Pokemon::search(), Message::PokemonFound)
}