mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-08-24 20:34:05 +02:00
Sweep orphaned response bodies at browser startup (#576)
This commit is contained in:
@@ -43,6 +43,10 @@ struct Host {
|
||||
events: mpsc::Receiver<ModelPayload>,
|
||||
}
|
||||
|
||||
fn lifecycle_host() -> yaak_lifecycle::Host {
|
||||
yaak_lifecycle::Host::owner()
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
static HOST: RefCell<Option<Host>> = const { RefCell::new(None) };
|
||||
}
|
||||
@@ -91,6 +95,10 @@ pub async fn boot() -> Result<()> {
|
||||
let (queries, blobs, events) =
|
||||
yaak_models::init_standalone(DB_NAME, BLOB_DB_NAME).map_err(js_error)?;
|
||||
|
||||
if let Err(e) = yaak_lifecycle::on_launch(&lifecycle_host(), &queries.connect(), &blobs) {
|
||||
web_sys::console::warn_2(&"on_launch hook failed".into(), &js_error(e));
|
||||
}
|
||||
|
||||
HOST.with(|h| *h.borrow_mut() = Some(Host { queries, blobs, events }));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user