From ba06d458d33d98bfaa5e66b3512ce7f063e8d7ba Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 14 Dec 2019 04:12:42 +0100 Subject: Move native events subscription to `iced_native` --- native/src/subscription.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'native/src/subscription.rs') diff --git a/native/src/subscription.rs b/native/src/subscription.rs index 4d000490..c25e1cb4 100644 --- a/native/src/subscription.rs +++ b/native/src/subscription.rs @@ -4,3 +4,28 @@ pub type Subscription = iced_core::Subscription; pub type Input = futures::channel::mpsc::Receiver; pub use iced_core::subscription::Recipe; + +pub fn events() -> Subscription { + Subscription::from_recipe(Events) +} + +struct Events; + +impl Recipe for Events { + type Output = Event; + + fn hash(&self, state: &mut Hasher) { + use std::hash::Hash; + + std::any::TypeId::of::().hash(state); + } + + fn stream( + self: Box, + input: Input, + ) -> futures::stream::BoxStream<'static, Self::Output> { + use futures::StreamExt; + + input.boxed() + } +} -- cgit