summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
Diffstat (limited to 'native')
-rw-r--r--native/src/subscription.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/native/src/subscription.rs b/native/src/subscription.rs
index 4d000490..c25e1cb4 100644
--- a/native/src/subscription.rs
+++ b/native/src/subscription.rs
@@ -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()
+ }
+}