Eliminate several singletons

just for better lifecycle management

Signed-off-by: x1a0b0 <xbtseng@gmail.com>
This commit is contained in:
x1a0b0
2025-10-13 14:20:11 +08:00
parent 61943b16ac
commit 7b473ad86a
6 changed files with 144 additions and 80 deletions
+9 -8
View File
@@ -53,14 +53,15 @@ async fn main() {
on_started().await;
}
KwsMonitor::start(|event| async move {
match event {
KwsMonitorEvent::Started => on_started().await,
KwsMonitorEvent::Keyword(keyword) => on_keyword(keyword).await,
}
Ok(())
})
.await;
KwsMonitor::new()
.start(|event| async move {
match event {
KwsMonitorEvent::Started => on_started().await,
KwsMonitorEvent::Keyword(keyword) => on_keyword(keyword).await,
}
Ok(())
})
.await;
loop {
tokio::time::sleep(std::time::Duration::from_secs(1)).await;