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

@ -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)