1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 05:10:03 -04:00

[egui_web] Simplify the arguments you pass to start()

This commit is contained in:
Emil Ernerfeldt
2020-12-19 21:15:07 +01:00
parent 8f034d391d
commit fb941cf618
4 changed files with 12 additions and 7 deletions

View File

@@ -221,9 +221,17 @@ impl AppRunner {
}
}
/// Install event listeners to register different input events
/// and starts running the given app.
pub fn start(canvas_id: &str, app: Box<dyn App>) -> Result<AppRunnerRef, JsValue> {
let backend = WebBackend::new(canvas_id)?;
let runner = AppRunner::new(backend, app)?;
start_runner(runner)
}
/// Install event listeners to register different input events
/// and starts running the given `AppRunner`.
pub fn start(app_runner: AppRunner) -> Result<AppRunnerRef, JsValue> {
fn start_runner(app_runner: AppRunner) -> Result<AppRunnerRef, JsValue> {
let runner_ref = AppRunnerRef(Arc::new(Mutex::new(app_runner)));
install_canvas_events(&runner_ref)?;
install_document_events(&runner_ref)?;