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

eframe web: access app from WebHandle (#1886)

Co-authored-by: Stanislav <enomado@users.noreply.github.com>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
Stanislav
2022-09-09 09:22:46 +03:00
committed by GitHub
parent e0c7533ede
commit ebc4fc866d
8 changed files with 80 additions and 1 deletions

View File

@@ -6,6 +6,9 @@
#![warn(missing_docs)] // Let's keep `epi` well-documented.
#[cfg(target_arch = "wasm32")]
use std::any::Any;
#[cfg(not(target_arch = "wasm32"))]
pub use crate::native::run::RequestRepaintEvent;
#[cfg(not(target_arch = "wasm32"))]
@@ -66,6 +69,15 @@ pub trait App {
/// To force a repaint, call [`egui::Context::request_repaint`] at any time (e.g. from another thread).
fn update(&mut self, ctx: &egui::Context, frame: &mut Frame);
/// Handle to the app.
///
/// Can be used from web to interact or other external context
/// Implementation is needed, because downcasting Box<dyn App> -> Box<dyn Any> to get &ConcreteApp is not simple in current rust.
///
/// Just return &mut *self
#[cfg(target_arch = "wasm32")]
fn as_any_mut(&mut self) -> &mut dyn Any;
/// Called on shutdown, and perhaps at regular intervals. Allows you to save state.
///
/// Only called when the "persistence" feature is enabled.