try not double boxing

This commit is contained in:
Evan Almloff committed 2024-01-17 15:07:45 -06:00
1 parent 0c532c5e0c
commit dab87c0144
11 files changed
+166 -103

No files matched your search

+4 -5
View File
@@ -18,7 +18,6 @@ use dioxus_html::{
use std::{
cell::{Cell, RefCell},
collections::HashMap,
marker::PhantomData,
rc::Rc,
sync::Arc,
};
@@ -29,10 +28,10 @@ use tao::{
};
/// The single top-level object that manages all the running windows, assets, shortcuts, etc
pub(crate) struct App<Props: Clone + 'static> {
pub(crate) struct App {
// move the props into a cell so we can pop it out later to create the first window
// iOS panics if we create a window before the event loop is started, so we toss them into a cell
pub(crate) dioxus_config: Cell<Option<CrossPlatformConfig<Props>>>,
pub(crate) dioxus_config: Cell<Option<CrossPlatformConfig>>,
pub(crate) cfg: Cell<Option<Config>>,
// Stuff we need mutable access to
@@ -59,10 +58,10 @@ pub struct SharedContext {
pub(crate) target: EventLoopWindowTarget<UserWindowEvent>,
}
impl<Props: Clone + 'static> App<Props> {
impl App {
pub fn new(
cfg: Config,
dioxus_config: CrossPlatformConfig<Props>,
dioxus_config: CrossPlatformConfig,
) -> (EventLoop<UserWindowEvent>, Self) {
let event_loop = EventLoopBuilder::<UserWindowEvent>::with_user_event().build();
+3 -6
View File
@@ -10,10 +10,7 @@ use tao::event::{Event, StartCause, WindowEvent};
///
/// This will block the main thread, and *must* be spawned on the main thread. This function does not assume any runtime
/// and is equivalent to calling launch_with_props with the tokio feature disabled.
pub fn launch_with_props_blocking<Props: Clone + 'static>(
dioxus_cfg: CrossPlatformConfig<Props>,
desktop_config: Config,
) {
pub fn launch_with_props_blocking(dioxus_cfg: CrossPlatformConfig, desktop_config: Config) {
let (event_loop, mut app) = App::new(desktop_config, dioxus_cfg);
event_loop.run(move |window_event, _, control_flow| {
@@ -53,10 +50,10 @@ pub fn launch_with_props_blocking<Props: Clone + 'static>(
/// The desktop renderer platform
pub struct DesktopPlatform;
impl<Props: Clone + 'static> PlatformBuilder<Props> for DesktopPlatform {
impl PlatformBuilder for DesktopPlatform {
type Config = Config;
fn launch(config: dioxus_core::CrossPlatformConfig<Props>, platform_config: Self::Config) {
fn launch(config: dioxus_core::CrossPlatformConfig, platform_config: Self::Config) {
#[cfg(feature = "tokio")]
tokio::runtime::Builder::new_multi_thread()
.enable_all()