Skip to content

Commit

Permalink
Make use of AppRunnerRef
Browse files Browse the repository at this point in the history
Follow-up to #1650
  • Loading branch information
emilk committed Aug 2, 2022
1 parent 64496ca commit 263c9bd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
13 changes: 4 additions & 9 deletions eframe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,15 @@ pub use epi::*;
// ----------------------------------------------------------------------------
// When compiling for web

#[cfg(target_arch = "wasm32")]
use egui::mutex::Mutex;

#[cfg(target_arch = "wasm32")]
use std::sync::Arc;

#[cfg(target_arch = "wasm32")]
pub mod web;

#[cfg(target_arch = "wasm32")]
pub use wasm_bindgen;

#[cfg(target_arch = "wasm32")]
use web::AppRunner;
use web::AppRunnerRef;

#[cfg(target_arch = "wasm32")]
pub use web_sys;

Expand All @@ -107,7 +102,7 @@ pub use web_sys;
/// /// You can add more callbacks like this if you want to call in to your code.
/// #[cfg(target_arch = "wasm32")]
/// #[wasm_bindgen]
/// pub fn start(canvas_id: &str) -> Result<Arc<Mutex<AppRunner>>, eframe::wasm_bindgen::JsValue> {
/// pub fn start(canvas_id: &str) -> Result<AppRunnerRef>, 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))))
/// }
Expand All @@ -117,7 +112,7 @@ pub fn start_web(
canvas_id: &str,
web_options: WebOptions,
app_creator: AppCreator,
) -> Result<Arc<Mutex<AppRunner>>, wasm_bindgen::JsValue> {
) -> Result<AppRunnerRef, wasm_bindgen::JsValue> {
let handle = web::start(canvas_id, web_options, app_creator)?;

Ok(handle)
Expand Down
2 changes: 1 addition & 1 deletion eframe/src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub mod storage;
mod text_agent;

pub use backend::*;
use egui::Vec2;
pub use events::*;
pub use storage::*;

Expand All @@ -21,6 +20,7 @@ use std::sync::{
Arc,
};

use egui::Vec2;
use wasm_bindgen::prelude::*;
use web_sys::EventTarget;

Expand Down
10 changes: 2 additions & 8 deletions egui_demo_app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ pub(crate) mod frame_history;
mod wrap_app;

#[cfg(target_arch = "wasm32")]
use std::sync::Arc;

#[cfg(target_arch = "wasm32")]
use eframe::web::AppRunner;

#[cfg(target_arch = "wasm32")]
use egui::mutex::Mutex;
use eframe::web::AppRunnerRef;

pub use wrap_app::WrapApp;

Expand All @@ -31,7 +25,7 @@ use eframe::wasm_bindgen::{self, prelude::*};
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
pub struct WebHandle {
handle: Arc<Mutex<AppRunner>>,
handle: AppRunnerRef,
}

#[cfg(target_arch = "wasm32")]
Expand Down

0 comments on commit 263c9bd

Please sign in to comment.