summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-12-05 06:10:13 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-12-05 06:10:13 +0100
commitd575f4541126e2ab25908fe55c6805f16716b2a5 (patch)
tree9d5221fe201b64e2ec649228ebae26be819dbf58 /src
parente92ea48e8814b42fc566017db085ca9bdaf3c272 (diff)
downloadiced-d575f4541126e2ab25908fe55c6805f16716b2a5.tar.gz
iced-d575f4541126e2ab25908fe55c6805f16716b2a5.tar.bz2
iced-d575f4541126e2ab25908fe55c6805f16716b2a5.zip
Draft first version of event subscriptions :tada:
Diffstat (limited to 'src')
-rw-r--r--src/application.rs11
-rw-r--r--src/native.rs4
-rw-r--r--src/sandbox.rs6
3 files changed, 17 insertions, 4 deletions
diff --git a/src/application.rs b/src/application.rs
index a4d20e68..95113344 100644
--- a/src/application.rs
+++ b/src/application.rs
@@ -1,4 +1,4 @@
-use crate::{Command, Element, Settings};
+use crate::{Command, Element, Settings, Subscription};
/// An interactive cross-platform application.
///
@@ -117,6 +117,11 @@ pub trait Application: Sized {
/// [`Command`]: struct.Command.html
fn update(&mut self, message: Self::Message) -> Command<Self::Message>;
+ /// TODO
+ fn subscriptions(&self) -> Subscription<Self::Message> {
+ Subscription::none()
+ }
+
/// Returns the widgets to display in the [`Application`].
///
/// These widgets can produce __messages__ based on user interaction.
@@ -168,6 +173,10 @@ where
self.0.update(message)
}
+ fn subscriptions(&self) -> Subscription<Self::Message> {
+ self.0.subscriptions()
+ }
+
fn view(&mut self) -> Element<'_, Self::Message> {
self.0.view()
}
diff --git a/src/native.rs b/src/native.rs
index 3537dd52..e3733955 100644
--- a/src/native.rs
+++ b/src/native.rs
@@ -1,6 +1,6 @@
pub use iced_winit::{
- Align, Background, Color, Command, Font, HorizontalAlignment, Length,
- VerticalAlignment,
+ subscription, Align, Background, Color, Command, Font, HorizontalAlignment,
+ Length, Subscription, VerticalAlignment,
};
pub mod widget {
diff --git a/src/sandbox.rs b/src/sandbox.rs
index acf7f5e0..248aa152 100644
--- a/src/sandbox.rs
+++ b/src/sandbox.rs
@@ -1,4 +1,4 @@
-use crate::{Application, Command, Element, Settings};
+use crate::{Application, Command, Element, Settings, Subscription};
/// A sandboxed [`Application`].
///
@@ -149,6 +149,10 @@ where
Command::none()
}
+ fn subscriptions(&self) -> Subscription<T::Message> {
+ Subscription::none()
+ }
+
fn view(&mut self) -> Element<'_, T::Message> {
T::view(self)
}