yazi/yazi-shared/src/event/event.rs
2026-05-22 17:00:06 +08:00

30 lines
582 B
Rust

use tokio::sync::mpsc;
use yazi_shim::cell::RoCell;
use super::ActionCow;
static TX: RoCell<mpsc::UnboundedSender<Event>> = RoCell::new();
static RX: RoCell<mpsc::UnboundedReceiver<Event>> = RoCell::new();
#[derive(Debug)]
pub enum Event {
Call(ActionCow),
Seq(Vec<ActionCow>),
Term(yazi_term::event::Event),
Render(bool),
}
impl Event {
#[inline]
pub fn init() {
let (tx, rx) = mpsc::unbounded_channel();
TX.init(tx);
RX.init(rx);
}
#[inline]
pub fn take() -> mpsc::UnboundedReceiver<Self> { RX.drop() }
#[inline]
pub fn emit(self) { TX.send(self).ok(); }
}