summaryrefslogtreecommitdiffstats
path: root/examples/multi_window/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/multi_window/src/main.rs')
-rw-r--r--examples/multi_window/src/main.rs16
1 files changed, 11 insertions, 5 deletions
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<window::Id, Window>,
}
@@ -43,6 +39,16 @@ enum Message {
}
impl Example {
+ fn new() -> (Self, Task<Message>) {
+ (
+ Self {
+ windows: BTreeMap::new(),
+ },
+ window::open(window::Settings::default())
+ .map(Message::WindowOpened),
+ )
+ }
+
fn title(&self, window: window::Id) -> String {
self.windows
.get(&window)