diff options
| author | 2024-06-16 20:24:41 +0200 | |
|---|---|---|
| committer | 2024-06-16 20:24:41 +0200 | |
| commit | 95d4adb55e485c01eec839736f328be26f2ccab6 (patch) | |
| tree | 2676e3cb8ec17c5bf1cd561d97932ae302551dfd /runtime/src/multi_window | |
| parent | e6d0b3bda5042a1017a5944a5227c97e0ed6caf9 (diff) | |
| parent | b5c5a016c4f2b608a740b37c494186557a064f48 (diff) | |
| download | iced-95d4adb55e485c01eec839736f328be26f2ccab6.tar.gz iced-95d4adb55e485c01eec839736f328be26f2ccab6.tar.bz2 iced-95d4adb55e485c01eec839736f328be26f2ccab6.zip | |
Merge pull request #2463 from iced-rs/task-api
`Task` API
Diffstat (limited to '')
| -rw-r--r-- | runtime/src/multi_window/program.rs | 8 | ||||
| -rw-r--r-- | runtime/src/multi_window/state.rs | 18 | 
2 files changed, 12 insertions, 14 deletions
| diff --git a/runtime/src/multi_window/program.rs b/runtime/src/multi_window/program.rs index 963a09d7..e8c71b26 100644 --- a/runtime/src/multi_window/program.rs +++ b/runtime/src/multi_window/program.rs @@ -2,7 +2,7 @@  use crate::core::text;  use crate::core::window;  use crate::core::{Element, Renderer}; -use crate::Command; +use crate::Task;  /// The core of a user interface for a multi-window application following The Elm Architecture.  pub trait Program: Sized { @@ -21,9 +21,9 @@ pub trait Program: Sized {      /// produced by either user interactions or commands, will be handled by      /// this method.      /// -    /// Any [`Command`] returned will be executed immediately in the -    /// background by shells. -    fn update(&mut self, message: Self::Message) -> Command<Self::Message>; +    /// Any [`Task`] returned will be executed immediately in the background by the +    /// runtime. +    fn update(&mut self, message: Self::Message) -> Task<Self::Message>;      /// Returns the widgets to display in the [`Program`] for the `window`.      /// diff --git a/runtime/src/multi_window/state.rs b/runtime/src/multi_window/state.rs index 10366ec0..72ce6933 100644 --- a/runtime/src/multi_window/state.rs +++ b/runtime/src/multi_window/state.rs @@ -5,7 +5,7 @@ use crate::core::renderer;  use crate::core::widget::operation::{self, Operation};  use crate::core::{Clipboard, Size};  use crate::user_interface::{self, UserInterface}; -use crate::{Command, Debug, Program}; +use crate::{Debug, Program, Task};  /// The execution state of a multi-window [`Program`]. It leverages caching, event  /// processing, and rendering primitive storage. @@ -85,7 +85,7 @@ where      /// the widgets of the linked [`Program`] if necessary.      ///      /// Returns a list containing the instances of [`Event`] that were not -    /// captured by any widget, and the [`Command`] obtained from [`Program`] +    /// captured by any widget, and the [`Task`] obtained from [`Program`]      /// after updating it, only if an update was necessary.      pub fn update(          &mut self, @@ -96,7 +96,7 @@ where          style: &renderer::Style,          clipboard: &mut dyn Clipboard,          debug: &mut Debug, -    ) -> (Vec<Event>, Option<Command<P::Message>>) { +    ) -> (Vec<Event>, Option<Task<P::Message>>) {          let mut user_interfaces = build_user_interfaces(              &self.program,              self.caches.take().unwrap(), @@ -163,14 +163,14 @@ where              drop(user_interfaces); -            let commands = Command::batch(messages.into_iter().map(|msg| { +            let commands = Task::batch(messages.into_iter().map(|msg| {                  debug.log_message(&msg);                  debug.update_started(); -                let command = self.program.update(msg); +                let task = self.program.update(msg);                  debug.update_finished(); -                command +                task              }));              let mut user_interfaces = build_user_interfaces( @@ -205,7 +205,7 @@ where      pub fn operate(          &mut self,          renderer: &mut P::Renderer, -        operations: impl Iterator<Item = Box<dyn Operation<P::Message>>>, +        operations: impl Iterator<Item = Box<dyn Operation<()>>>,          bounds: Size,          debug: &mut Debug,      ) { @@ -227,9 +227,7 @@ where                  match operation.finish() {                      operation::Outcome::None => {} -                    operation::Outcome::Some(message) => { -                        self.queued_messages.push(message); -                    } +                    operation::Outcome::Some(()) => {}                      operation::Outcome::Chain(next) => {                          current_operation = Some(next);                      } | 
