Rename iced_sentinel to iced_beacon and refactor its API
This commit is contained in:
parent
aaf396256e
commit
57033dc4d0
19 changed files with 596 additions and 438 deletions
15
beacon/src/stream.rs
Normal file
15
beacon/src/stream.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
use futures::channel::mpsc;
|
||||
use futures::stream::{self, Stream, StreamExt};
|
||||
use futures::Future;
|
||||
|
||||
pub fn channel<T, F>(f: impl Fn(mpsc::Sender<T>) -> F) -> impl Stream<Item = T>
|
||||
where
|
||||
F: Future<Output = ()>,
|
||||
{
|
||||
let (sender, receiver) = mpsc::channel(1);
|
||||
|
||||
stream::select(
|
||||
receiver,
|
||||
stream::once(f(sender)).filter_map(|_| async { None }),
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue