Runtime::close implemented
@@ -4,6 +4,8 @@ use derivative::Derivative;
use enclose::enclose;
use futures::channel::mpsc::{channel, Receiver, Sender};
use futures::FutureExt;
+#[cfg(test)]
+use futures::SinkExt;
use serde::Serialize;
use std::marker::PhantomData;
use std::sync::{Arc, LockResult, RwLock, RwLockReadGuard};
@@ -60,6 +62,12 @@ where
};
self.handle_effects(effects);
}
+ #[cfg(test)]
+ pub async fn close(&mut self) -> Result<(), anyhow::Error> {
+ self.tx.flush().await?;
+ self.tx.close_channel();
+ Ok(())
+ }
fn emit(&self, event: RuntimeEvent) {
self.tx.clone().try_send(event).expect("emit event failed");
}
