summaryrefslogtreecommitdiffstats
path: root/native/src/subscription.rs
diff options
context:
space:
mode:
Diffstat (limited to 'native/src/subscription.rs')
-rw-r--r--native/src/subscription.rs27
1 files changed, 26 insertions, 1 deletions
diff --git a/native/src/subscription.rs b/native/src/subscription.rs
index 980a8116..4c0d80a7 100644
--- a/native/src/subscription.rs
+++ b/native/src/subscription.rs
@@ -59,8 +59,11 @@ pub fn events_with<Message>(
where
Message: 'static + MaybeSend,
{
+ #[derive(Hash)]
+ struct EventsWith;
+
Subscription::from_recipe(Runner {
- id: f,
+ id: (EventsWith, f),
spawn: move |events| {
use futures::future;
use futures::stream::StreamExt;
@@ -75,6 +78,28 @@ where
})
}
+pub(crate) fn raw_events<Message>(
+ f: fn(Event, event::Status) -> Option<Message>,
+) -> Subscription<Message>
+where
+ Message: 'static + MaybeSend,
+{
+ #[derive(Hash)]
+ struct RawEvents;
+
+ Subscription::from_recipe(Runner {
+ id: (RawEvents, f),
+ spawn: move |events| {
+ use futures::future;
+ use futures::stream::StreamExt;
+
+ events.filter_map(move |(event, status)| {
+ future::ready(f(event, status))
+ })
+ },
+ })
+}
+
/// Returns a [`Subscription`] that will create and asynchronously run the
/// given [`Stream`].
///