diff options
author | 2019-12-14 04:12:42 +0100 | |
---|---|---|
committer | 2019-12-14 04:12:42 +0100 | |
commit | ba06d458d33d98bfaa5e66b3512ce7f063e8d7ba (patch) | |
tree | 52e9ea551c2c63943fab3ebd7e24263480b5bbce /examples/events.rs | |
parent | e71978456a0af40a1004a5c5ce1c7cdc8b709ac0 (diff) | |
download | iced-ba06d458d33d98bfaa5e66b3512ce7f063e8d7ba.tar.gz iced-ba06d458d33d98bfaa5e66b3512ce7f063e8d7ba.tar.bz2 iced-ba06d458d33d98bfaa5e66b3512ce7f063e8d7ba.zip |
Move native events subscription to `iced_native`
Diffstat (limited to 'examples/events.rs')
-rw-r--r-- | examples/events.rs | 42 |
1 files changed, 7 insertions, 35 deletions
diff --git a/examples/events.rs b/examples/events.rs index f9e606d8..0b944495 100644 --- a/examples/events.rs +++ b/examples/events.rs @@ -49,7 +49,7 @@ impl Application for Events { fn subscriptions(&self) -> Subscription<Message> { if self.enabled { - events::all().map(Message::EventOccurred) + iced_native::subscription::events().map(Message::EventOccurred) } else { Subscription::none() } @@ -67,8 +67,12 @@ impl Application for Events { }, ); - let toggle = Checkbox::new(self.enabled, "Enabled", Message::Toggled) - .width(Length::Shrink); + let toggle = Checkbox::new( + self.enabled, + "Listen to runtime events", + Message::Toggled, + ) + .width(Length::Shrink); let content = Column::new() .width(Length::Shrink) @@ -85,35 +89,3 @@ impl Application for Events { .into() } } - -mod events { - pub fn all() -> iced::Subscription<iced_native::Event> { - iced::Subscription::from_recipe(All) - } - - struct All; - - impl - iced_native::subscription::Recipe< - iced_native::Hasher, - iced_native::subscription::Input, - > for All - { - type Output = iced_native::Event; - - fn hash(&self, state: &mut iced_native::Hasher) { - use std::hash::Hash; - - std::any::TypeId::of::<All>().hash(state); - } - - fn stream( - self: Box<Self>, - input: iced_native::subscription::Input, - ) -> futures::stream::BoxStream<'static, Self::Output> { - use futures::StreamExt; - - input.boxed() - } - } -} |