Move native events subscription to iced_native
This commit is contained in:
parent
e71978456a
commit
ba06d458d3
2 changed files with 32 additions and 35 deletions
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue