From a25b1af45690bdd8e1cbb20ee3a5b1c4342de455 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 14 Jun 2024 01:47:39 +0200 Subject: Replace `Command` with a new `Task` API with chain support --- src/application.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/application.rs') diff --git a/src/application.rs b/src/application.rs index d12ba73d..4cd4a87d 100644 --- a/src/application.rs +++ b/src/application.rs @@ -2,7 +2,7 @@ use crate::core::text; use crate::graphics::compositor; use crate::shell::application; -use crate::{Command, Element, Executor, Settings, Subscription}; +use crate::{Element, Executor, Settings, Subscription, Task}; pub use application::{Appearance, DefaultStyle}; @@ -16,7 +16,7 @@ pub use application::{Appearance, DefaultStyle}; /// document. /// /// An [`Application`] can execute asynchronous actions by returning a -/// [`Command`] in some of its methods. +/// [`Task`] in some of its methods. /// /// When using an [`Application`] with the `debug` feature enabled, a debug view /// can be toggled by pressing `F12`. @@ -62,7 +62,7 @@ pub use application::{Appearance, DefaultStyle}; /// ```no_run /// use iced::advanced::Application; /// use iced::executor; -/// use iced::{Command, Element, Settings, Theme, Renderer}; +/// use iced::{Task, Element, Settings, Theme, Renderer}; /// /// pub fn main() -> iced::Result { /// Hello::run(Settings::default()) @@ -77,16 +77,16 @@ pub use application::{Appearance, DefaultStyle}; /// type Theme = Theme; /// type Renderer = Renderer; /// -/// fn new(_flags: ()) -> (Hello, Command) { -/// (Hello, Command::none()) +/// fn new(_flags: ()) -> (Hello, Task) { +/// (Hello, Task::none()) /// } /// /// fn title(&self) -> String { /// String::from("A cool application") /// } /// -/// fn update(&mut self, _message: Self::Message) -> Command { -/// Command::none() +/// fn update(&mut self, _message: Self::Message) -> Task { +/// Task::none() /// } /// /// fn view(&self) -> Element { @@ -123,12 +123,12 @@ where /// /// Here is where you should return the initial state of your app. /// - /// Additionally, you can return a [`Command`] if you need to perform some + /// Additionally, you can return a [`Task`] if you need to perform some /// async action in the background on startup. This is useful if you want to /// load state from a file, perform an initial HTTP request, etc. /// /// [`run`]: Self::run - fn new(flags: Self::Flags) -> (Self, Command); + fn new(flags: Self::Flags) -> (Self, Task); /// Returns the current title of the [`Application`]. /// @@ -142,8 +142,8 @@ where /// produced by either user interactions or commands, will be handled by /// this method. /// - /// Any [`Command`] returned will be executed immediately in the background. - fn update(&mut self, message: Self::Message) -> Command; + /// Any [`Task`] returned will be executed immediately in the background. + fn update(&mut self, message: Self::Message) -> Task; /// Returns the widgets to display in the [`Application`]. /// @@ -234,7 +234,7 @@ where type Theme = A::Theme; type Renderer = A::Renderer; - fn update(&mut self, message: Self::Message) -> Command { + fn update(&mut self, message: Self::Message) -> Task { self.0.update(message) } @@ -250,7 +250,7 @@ where { type Flags = A::Flags; - fn new(flags: Self::Flags) -> (Self, Command) { + fn new(flags: Self::Flags) -> (Self, Task) { let (app, command) = A::new(flags); (Instance(app), command) -- cgit