2019-12-10 03:43:00 +01:00
|
|
|
use crate::{Event, Hasher};
|
2019-12-08 08:21:26 +01:00
|
|
|
|
2019-12-10 03:43:00 +01:00
|
|
|
pub type Subscription<T> = iced_core::Subscription<Hasher, Input, T>;
|
2019-12-08 08:21:26 +01:00
|
|
|
pub type Input = futures::channel::mpsc::Receiver<Event>;
|
|
|
|
|
|
2019-12-10 03:43:00 +01:00
|
|
|
pub use iced_core::subscription::Recipe;
|
2019-12-14 04:12:42 +01:00
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
}
|
|
|
|
|
}
|