Move native events subscription to iced_native

This commit is contained in:
Héctor Ramón Jiménez 2019-12-14 04:12:42 +01:00
parent e71978456a
commit ba06d458d3
2 changed files with 32 additions and 35 deletions

View file

@ -4,3 +4,28 @@ pub type Subscription<T> = iced_core::Subscription<Hasher, Input, T>;
pub type Input = futures::channel::mpsc::Receiver<Event>;
pub use iced_core::subscription::Recipe;
pub fn events() -> Subscription<Event> {
Subscription::from_recipe(Events)
}
struct Events;
impl Recipe<Hasher, Input> for Events {
type Output = Event;
fn hash(&self, state: &mut Hasher) {
use std::hash::Hash;
std::any::TypeId::of::<Self>().hash(state);
}
fn stream(
self: Box<Self>,
input: Input,
) -> futures::stream::BoxStream<'static, Self::Output> {
use futures::StreamExt;
input.boxed()
}
}