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