From e86920be5b9984b4eb511e5e69efdcbf6ef3d8e4 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 9 Jul 2024 00:28:40 +0200 Subject: Remove `load` method from `application` and `daemon` If you need to run a `Task` during boot, use `run_with` instead! --- examples/multi_window/src/main.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'examples/multi_window') diff --git a/examples/multi_window/src/main.rs b/examples/multi_window/src/main.rs index 98e753ab..460ca3b5 100644 --- a/examples/multi_window/src/main.rs +++ b/examples/multi_window/src/main.rs @@ -9,16 +9,12 @@ use std::collections::BTreeMap; fn main() -> iced::Result { iced::daemon(Example::title, Example::update, Example::view) - .load(|| { - window::open(window::Settings::default()).map(Message::WindowOpened) - }) .subscription(Example::subscription) .theme(Example::theme) .scale_factor(Example::scale_factor) - .run() + .run_with(Example::new) } -#[derive(Default)] struct Example { windows: BTreeMap, } @@ -43,6 +39,16 @@ enum Message { } impl Example { + fn new() -> (Self, Task) { + ( + Self { + windows: BTreeMap::new(), + }, + window::open(window::Settings::default()) + .map(Message::WindowOpened), + ) + } + fn title(&self, window: window::Id) -> String { self.windows .get(&window) -- cgit