Use iced_futures utilities to make native work under wasm32 target.
This commit is contained in:
parent
55eaeceec8
commit
24d7d4740f
2 changed files with 6 additions and 7 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
//! Listen to external events in your application.
|
//! Listen to external events in your application.
|
||||||
use crate::event::{self, Event};
|
use crate::event::{self, Event};
|
||||||
use crate::Hasher;
|
use crate::Hasher;
|
||||||
use iced_futures::futures::stream::BoxStream;
|
use iced_futures::BoxStream;
|
||||||
|
|
||||||
/// A request to listen to external events.
|
/// A request to listen to external events.
|
||||||
///
|
///
|
||||||
|
|
@ -21,7 +21,7 @@ pub type Subscription<T> =
|
||||||
/// A stream of runtime events.
|
/// A stream of runtime events.
|
||||||
///
|
///
|
||||||
/// It is the input of a [`Subscription`] in the native runtime.
|
/// It is the input of a [`Subscription`] in the native runtime.
|
||||||
pub type EventStream = BoxStream<'static, (Event, event::Status)>;
|
pub type EventStream = BoxStream<(Event, event::Status)>;
|
||||||
|
|
||||||
/// A native [`Subscription`] tracker.
|
/// A native [`Subscription`] tracker.
|
||||||
pub type Tracker =
|
pub type Tracker =
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,9 @@ where
|
||||||
self: Box<Self>,
|
self: Box<Self>,
|
||||||
event_stream: EventStream,
|
event_stream: EventStream,
|
||||||
) -> BoxStream<Self::Output> {
|
) -> BoxStream<Self::Output> {
|
||||||
event_stream
|
let stream = event_stream.filter_map(move |(event, status)| {
|
||||||
.filter_map(move |(event, status)| {
|
future::ready((self.f)(event, status))
|
||||||
future::ready((self.f)(event, status))
|
});
|
||||||
})
|
iced_futures::boxed_stream(stream)
|
||||||
.boxed()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue