pub fn future_to_promise<F>(future: F) -> Promise where
F: Future<Item = JsValue, Error = JsValue> + 'static,
Converts a Rust
This function will take any future in Rust and schedule it to be executed,
to get plumbed into the rest of a system.
future provided must adhere to
'static because it'll be scheduled
to run in the background and cannot contain any stack references. The
Promise will be resolved or rejected when the future completes,
depending on whether it finishes with
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!