spawn_local

Function spawn_local 

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

Runs a Rust Future on the current thread.

The future must be 'static because it will be scheduled to run in the background and cannot contain any stack references.

The future will always be run on the next microtask tick even if it immediately returns Poll::Ready.

§Panics

Note that in wasm panics are currently translated to aborts, but “abort” in this case means that a JavaScript exception is thrown. The wasm module is still usable (likely erroneously) after Rust panics.

If the future provided panics then the returned Promise will not resolve. Instead it will be a leaked promise. This is an unfortunate limitation of wasm currently that’s hoped to be fixed one day!