diff options
author | 2019-12-14 04:49:13 +0100 | |
---|---|---|
committer | 2019-12-14 04:49:13 +0100 | |
commit | 293314405f5b8d4003db5ef8f428e659ae36872d (patch) | |
tree | 0ae1f11d0347e53423568969397d8636e029c726 /native/src/subscription.rs | |
parent | ba06d458d33d98bfaa5e66b3512ce7f063e8d7ba (diff) | |
download | iced-293314405f5b8d4003db5ef8f428e659ae36872d.tar.gz iced-293314405f5b8d4003db5ef8f428e659ae36872d.tar.bz2 iced-293314405f5b8d4003db5ef8f428e659ae36872d.zip |
Make `iced_native` subscription input opaque
Diffstat (limited to '')
-rw-r--r-- | native/src/subscription.rs | 31 |
1 files changed, 8 insertions, 23 deletions
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<T> = iced_core::Subscription<Hasher, Input, T>; -pub type Input = futures::channel::mpsc::Receiver<Event>; +pub type EventStream = BoxStream<'static, Event>; -pub use iced_core::subscription::Recipe; - -pub fn events() -> Subscription<Event> { - Subscription::from_recipe(Events) -} +pub type Subscription<T> = iced_core::Subscription<Hasher, EventStream, T>; -struct Events; - -impl Recipe<Hasher, Input> 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::<Self>().hash(state); - } +mod events; - fn stream( - self: Box<Self>, - input: Input, - ) -> futures::stream::BoxStream<'static, Self::Output> { - use futures::StreamExt; +use events::Events; - input.boxed() - } +pub fn events() -> Subscription<Event> { + Subscription::from_recipe(Events) } |