Skip to main content

spawn_local

Function spawn_local 

Source
pub fn spawn_local<F>(future: F)
where F: Future<Output = ()> + 'static,
Expand description

Schedule a task in the JS Event Loop to drive the Rust future.

This is a wrapper for js_sys::futures::spawn_local that hooks into the worker thread’s runtime to handle any panics in the async task. This version of spawn_local will ensure the join handle is notified of the panic and the worker is terminated. Without this wrapper, async panics might leave the main thread’s future hanging forever.