[−][src]Function div::load_js_class
pub fn load_js_class(
name: &str,
src: &str
) -> Result<impl Future<Output = JsClassHandle>, DivError>
Experimental: This API is experimental and my not be included in later versions
Load a class named name
from a JS file accessible at src
.
Returns a Future because the script is loaded asynchronously.
That future will have to be handled in one way or another.
The most direct way would be to use wasm_bindgen_futures::spawn_local
Example
const X: u32 = 100; const Y: u32 = 100; const W: u32 = 500; const H: u32 = 500; let future = async { let class = div::load_js_class("Test", "./Test.js").unwrap().await; div::from_js_class(X, Y, W, H, class).unwrap(); }; wasm_bindgen_futures::spawn_local(future);