1use futures::{future, Future, FutureExt as _};
9
10pub type NonBlockingFuture<R> = future::RemoteHandle<R>;
12
13#[cfg(not(web))]
15pub fn spawn<F: Future<Output: Send> + Send + 'static>(future: F) -> NonBlockingFuture<F::Output> {
16 let (future, remote_handle) = future.remote_handle();
17 tokio::task::spawn(future);
18 remote_handle
19}
20
21#[cfg(web)]
23pub fn spawn<F: Future + 'static>(future: F) -> NonBlockingFuture<F::Output> {
24 let (future, remote_handle) = future.remote_handle();
25 wasm_bindgen_futures::spawn_local(future);
26 remote_handle
27}