use cfg_if::cfg_if;
use std::future::Future;
pub trait AsyncRuntime: Send + Sync + 'static {}
pub fn spawn<F>(future: F)
where
F: Future<Output = ()> + Send + 'static,
{
cfg_if! {
if #[cfg(target_arch = "wasm32")] {
wasm_bindgen_futures::spawn_local(future);
} else {
tokio::spawn(future);
}
}
}
pub fn spawn_local<F>(future: F)
where
F: Future<Output = ()> + 'static,
{
cfg_if! {
if #[cfg(target_arch = "wasm32")] {
wasm_bindgen_futures::spawn_local(future);
} else {
tokio::task::spawn_local(future);
}
}
}