Plug Emulator into devtools 🎉

This commit is contained in:
Héctor Ramón Jiménez 2025-05-31 05:50:25 +02:00
parent 16556b51bc
commit ed528c9c53
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
4 changed files with 158 additions and 32 deletions

View file

@ -2,7 +2,7 @@
use crate::subscription;
use crate::{BoxStream, Executor, MaybeSend};
use futures::{Sink, channel::mpsc};
use futures::{Sink, SinkExt, channel::mpsc};
use std::marker::PhantomData;
/// A batteries-included runtime of commands and subscriptions.
@ -79,6 +79,15 @@ where
self.executor.spawn(future);
}
/// Sends a message concurrently through the [`Runtime`].
pub fn send(&mut self, message: Message) {
let mut sender = self.sender.clone();
self.executor.spawn(async move {
let _ = sender.send(message).await;
});
}
/// Tracks a [`Subscription`] in the [`Runtime`].
///
/// It will spawn new streams or close old ones as necessary! See