Skip to content

Commit

Permalink
feat: add spawn local fn
Browse files Browse the repository at this point in the history
  • Loading branch information
S0c5 committed Jul 25, 2024
1 parent 095a953 commit 93196e2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion sube/src/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ use serde::Deserialize;
#[cfg(not(feature = "js"))]
use async_std::task::spawn;
#[cfg(feature = "js")]
use async_std::task::spawn_local as spawn;
use async_std::task::{Builder, JoinHandle};

#[cfg(feature = "js")]
pub fn spawn_local<F, T>(future: F) -> JoinHandle<T>
where
F: futures_util::Future<Output = T> + 'static,
T: 'static,
{
#[cfg(feature = "js")]
Builder::new().local(future).expect("cannot spawn task")
}

use crate::{
rpc::{self, Rpc, RpcResult},
Expand Down

0 comments on commit 93196e2

Please sign in to comment.