1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 22:30:03 -04:00

Simplify interface

This commit is contained in:
Emil Ernerfeldt
2022-08-20 10:04:12 +02:00
parent d3e26cd00a
commit ba9d1e446c
2 changed files with 6 additions and 18 deletions

View File

@@ -32,7 +32,6 @@ pub struct WebHandle {
#[wasm_bindgen]
impl WebHandle {
#[wasm_bindgen]
#[cfg(target_arch = "wasm32")]
pub fn stop_web(&self) -> Result<(), wasm_bindgen::JsValue> {
let mut app = self.handle.lock();
let res = app.destroy();
@@ -44,22 +43,10 @@ impl WebHandle {
res
}
// helper for mutating original app from javascript
fn with_app<F>(&mut self, func: F) -> ()
where
F: Fn(&mut WrapApp) -> (),
{
let mut runner_ref = self.handle.lock();
let app_ref = runner_ref.get_app_mut();
let app = app_ref.downcast_mut::<WrapApp>().unwrap();
func(app);
}
#[wasm_bindgen]
pub fn set_some_content_from_javasript(&mut self, _some_data: &str) {
self.with_app(|_app| {
// app.data = some_data;
});
let _app = self.handle.lock().app_mut::<WrapApp>();
// _app.data = some_data;
}
}