Fix input events and drop spawning tokio
This commit is contained in:
+5
-3
@@ -38,9 +38,11 @@ pub async fn run<A: App>(create_app: impl FnOnce(&state::Context) -> A) {
|
||||
crossterm::terminal::enable_raw_mode().unwrap();
|
||||
|
||||
tokio::spawn(async move {
|
||||
tx.send(Box::new(crossterm::event::read().unwrap()))
|
||||
.await
|
||||
.unwrap();
|
||||
loop {
|
||||
tx.send(Box::new(crossterm::event::read().unwrap()))
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
});
|
||||
|
||||
let mut app = create_app(&ctx);
|
||||
|
||||
@@ -59,7 +59,9 @@ impl<'a, T> std::ops::DerefMut for StateGuard<'a, T> {
|
||||
impl<'a, T> Drop for StateGuard<'a, T> {
|
||||
fn drop(&mut self) {
|
||||
if self.is_mutated {
|
||||
self.tx.blocking_send(Box::new(Refresh)).unwrap()
|
||||
let tx = self.tx.clone();
|
||||
|
||||
tokio::spawn(async move { tx.send(Box::new(Refresh)).await.unwrap() });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user