Make it run in browser

This commit is contained in:
2025-12-28 23:24:18 +01:00
parent ac82875a3d
commit 258ae03cec
7 changed files with 298 additions and 232 deletions
+20
View File
@@ -0,0 +1,20 @@
#[cfg(not(target_arch = "wasm32"))]
use std::sync::LazyLock;
#[cfg(not(target_arch = "wasm32"))]
pub static RT: LazyLock<tokio::runtime::Runtime> = LazyLock::new(|| {
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.expect("Failed to initialize tokio runtime")
});
#[cfg(not(target_arch = "wasm32"))]
pub fn spawn(f: impl Future<Output = ()> + Send + 'static) {
RT.spawn(f);
}
#[cfg(target_arch = "wasm32")]
pub fn spawn(f: impl Future<Output = ()> + 'static) {
wasm_bindgen_futures::spawn_local(f);
}