feat:IInline math equation (#2949)

This commit is contained in:
Lucas.Xu
2023-07-09 10:03:22 +07:00
committed by GitHub
parent 4c17298432
commit ff9b3c56c5
43 changed files with 500 additions and 120 deletions

View File

@ -14,6 +14,10 @@ lazy_static! {
static ref NOTIFICATION_SENDER: RwLock<Vec<Box<dyn NotificationSender>>> = RwLock::new(vec![]);
}
/// Register a notification sender. The sender will be alive until the process exits.
/// Flutter integration test or Tauri hot reload might cause register multiple times.
/// So before register a new sender, you might need to unregister the old one. Currently,
/// Just remove all senders by calling `unregister_all_notification_sender`.
pub fn register_notification_sender<T: NotificationSender>(sender: T) {
let box_sender = Box::new(sender);
match NOTIFICATION_SENDER.write() {
@ -22,6 +26,13 @@ pub fn register_notification_sender<T: NotificationSender>(sender: T) {
}
}
pub fn unregister_all_notification_sender() {
match NOTIFICATION_SENDER.write() {
Ok(mut write_guard) => write_guard.clear(),
Err(err) => tracing::error!("Failed to remove all notification senders: {:?}", err),
}
}
pub trait NotificationSender: Send + Sync + 'static {
fn send_subject(&self, subject: SubscribeObject) -> Result<(), String>;
}