summaryrefslogtreecommitdiffstats
path: root/examples/todos
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-07-09 00:28:40 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-07-09 00:28:40 +0200
commite86920be5b9984b4eb511e5e69efdcbf6ef3d8e4 (patch)
tree82180c9fa4c7381c5af747f42efda83214fda176 /examples/todos
parent3d99da805dd42a062aa66a3bdc43c7cf82fa4fbe (diff)
downloadiced-e86920be5b9984b4eb511e5e69efdcbf6ef3d8e4.tar.gz
iced-e86920be5b9984b4eb511e5e69efdcbf6ef3d8e4.tar.bz2
iced-e86920be5b9984b4eb511e5e69efdcbf6ef3d8e4.zip
Remove `load` method from `application` and `daemon`
If you need to run a `Task` during boot, use `run_with` instead!
Diffstat (limited to 'examples/todos')
-rw-r--r--examples/todos/src/main.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/examples/todos/src/main.rs b/examples/todos/src/main.rs
index 6ed50d31..b34f71ce 100644
--- a/examples/todos/src/main.rs
+++ b/examples/todos/src/main.rs
@@ -18,16 +18,14 @@ pub fn main() -> iced::Result {
tracing_subscriber::fmt::init();
iced::application(Todos::title, Todos::update, Todos::view)
- .load(Todos::load)
.subscription(Todos::subscription)
.font(include_bytes!("../fonts/icons.ttf").as_slice())
.window_size((500.0, 800.0))
- .run()
+ .run_with(Todos::new)
}
-#[derive(Default, Debug)]
+#[derive(Debug)]
enum Todos {
- #[default]
Loading,
Loaded(State),
}
@@ -54,8 +52,11 @@ enum Message {
}
impl Todos {
- fn load() -> Command<Message> {
- Command::perform(SavedState::load(), Message::Loaded)
+ fn new() -> (Self, Command<Message>) {
+ (
+ Self::Loading,
+ Command::perform(SavedState::load(), Message::Loaded),
+ )
}
fn title(&self) -> String {