Draft first version of event subscriptions 🎉
This commit is contained in:
parent
e92ea48e88
commit
d575f45411
11 changed files with 182 additions and 12 deletions
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue