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:
parent
3d99da805d
commit
e86920be5b
10 changed files with 70 additions and 197 deletions
|
|
@ -13,12 +13,11 @@ use std::sync::Arc;
|
|||
|
||||
pub fn main() -> iced::Result {
|
||||
iced::application("Editor - Iced", Editor::update, Editor::view)
|
||||
.load(Editor::load)
|
||||
.subscription(Editor::subscription)
|
||||
.theme(Editor::theme)
|
||||
.font(include_bytes!("../fonts/icons.ttf").as_slice())
|
||||
.default_font(Font::MONOSPACE)
|
||||
.run()
|
||||
.run_with(Editor::new)
|
||||
}
|
||||
|
||||
struct Editor {
|
||||
|
|
@ -41,20 +40,22 @@ enum Message {
|
|||
}
|
||||
|
||||
impl Editor {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
file: None,
|
||||
content: text_editor::Content::new(),
|
||||
theme: highlighter::Theme::SolarizedDark,
|
||||
is_loading: true,
|
||||
is_dirty: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn load() -> Task<Message> {
|
||||
Task::perform(
|
||||
load_file(format!("{}/src/main.rs", env!("CARGO_MANIFEST_DIR"))),
|
||||
Message::FileOpened,
|
||||
fn new() -> (Self, Task<Message>) {
|
||||
(
|
||||
Self {
|
||||
file: None,
|
||||
content: text_editor::Content::new(),
|
||||
theme: highlighter::Theme::SolarizedDark,
|
||||
is_loading: true,
|
||||
is_dirty: false,
|
||||
},
|
||||
Task::perform(
|
||||
load_file(format!(
|
||||
"{}/src/main.rs",
|
||||
env!("CARGO_MANIFEST_DIR")
|
||||
)),
|
||||
Message::FileOpened,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -214,12 +215,6 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for Editor {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Error {
|
||||
DialogClosed,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue