2025-05-15 14:50:30 -07:00
|
|
|
use std::sync::mpsc::Sender;
|
|
|
|
|
|
|
|
|
|
use crate::app_event::AppEvent;
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
|
pub(crate) struct AppEventSender {
|
2025-08-06 19:39:07 -07:00
|
|
|
pub app_event_tx: Sender<AppEvent>,
|
2025-05-15 14:50:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl AppEventSender {
|
|
|
|
|
pub(crate) fn new(app_event_tx: Sender<AppEvent>) -> Self {
|
|
|
|
|
Self { app_event_tx }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Send an event to the app event channel. If it fails, we swallow the
|
|
|
|
|
/// error and log it.
|
|
|
|
|
pub(crate) fn send(&self, event: AppEvent) {
|
|
|
|
|
if let Err(e) = self.app_event_tx.send(event) {
|
|
|
|
|
tracing::error!("failed to send event: {e}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|