pub async fn start_web(
canvas_id: &str,
web_options: WebOptions,
app_creator: AppCreator
) -> Result<AppRunnerRef, JsValue>
Expand description
Install event listeners to register different input events and start running the given app.
#[cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*;
/// This is the entry-point for all the web-assembly.
/// This is called from the HTML.
/// It loads the app, installs some callbacks, then returns.
/// It returns a handle to the running app that can be stopped calling `AppRunner::stop_web`.
/// You can add more callbacks like this if you want to call in to your code.
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
pub struct WebHandle {
handle: AppRunnerRef,
}
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
pub async fn start(canvas_id: &str) -> Result<WebHandle, eframe::wasm_bindgen::JsValue> {
let web_options = eframe::WebOptions::default();
eframe::start_web(
canvas_id,
web_options,
Box::new(|cc| Box::new(MyEguiApp::new(cc))),
)
.await
.map(|handle| WebHandle { handle })
}
Errors
Failing to initialize WebGL graphics.