mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-26 19:21:35 +00:00
Add naive spawn_local implementation + tests
This is just a naive implementation. It seems it can be improved using a custom task queue, but that can be in a separate PR.
This commit is contained in:
@ -377,3 +377,15 @@ fn _future_to_promise(future: Box<Future<Item = JsValue, Error = JsValue>>) -> P
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Spawns a future.
|
||||
pub fn spawn_local<F>(future: F)
|
||||
where
|
||||
F: Future<Item = (), Error = ()> + 'static,
|
||||
{
|
||||
future_to_promise(
|
||||
future
|
||||
.map(|_| JsValue::undefined())
|
||||
.map_err(|_| JsValue::undefined()),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user