mirror of
https://github.com/hulthe/inkopslista.git
synced 2026-08-03 23:11:28 +02:00
Make it run in browser
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user